button not displaying right side of the layout in android

Try this,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="#FF0000"
        android:orientation="horizontal"
        android:weightSum="100" >

        <Button
            android:id="@+id/back"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_weight="20"
            android:background="@drawable/back" />

        <TextView
            android:id="@+id/tv"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="60"
            android:gravity="center"
            android:text="Hello"
            android:textStyle="bold" />

        <Button
            android:id="@+id/home"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_marginLeft="60dp"
            android:layout_weight="20"
            android:background="@drawable/home" />
    </LinearLayout>

</LinearLayout>

Leave a Comment