How to place three buttons for viewing images on one line in Android

I have three imageViews . Here I want to install all of these ImageViewon one line. I pasted my current xml code below.

  

    <RelativeLayout
        android:id="@+id/myFragement"
        android:layout_width="wrap_content"
        android:layout_height="306dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="44dp"
        android:layout_weight="1.77"
        android:orientation="horizontal" >
    </RelativeLayout>

     <ImageView
         android:id="@+id/login_button"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:src="@drawable/login_non_click" />

    <ImageView
        android:id="@+id/comapre_now_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/compare_now_non_click_state" />

    <ImageView
        android:id="@+id/search_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/comapre_now_button"
        android:src="@drawable/search_non_click" />

</RelativeLayout>

After i went. sent my application image, I think this is useful to everyone After editing i have posted my App's image i think this is helpful

After editing, I sent my application to all the Xml code, I think this is useful to everyone.

<RelativeLayout
    android:id="@+id/myFragement"
    android:layout_width="wrap_content"
    android:layout_height="306dp"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="44dp"
    android:layout_weight="1.77"
    android:orientation="horizontal" >

</RelativeLayout>

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="horizontal"
        android:weightSum="3" >
     <ImageView
             android:id="@+id/login_button"
                  android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"

             android:src="@drawable/login_non_click" />

        <ImageView
            android:id="@+id/comapre_now_button"
             android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
            android:src="@drawable/compare_now_non_click_state" />

        <ImageView
            android:id="@+id/search_button"
              android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
            android:src="@drawable/search_non_click" />

    </LinearLayout>

+3
source share
2 answers

, fida, , ( ). , , 1/3 . weight View View weight.

, , , android:layout_width="match_parent" ImageView, , . , android:layout_width="wrap_content". , , android:layout_below="@+id/comapre_now_button", , , View id.

, , , , android:layout_centerHorizontal="true" android:layout_toRightOf="@id/someId" android:layout_toLeftOf="id/someId"

, , RelativeLayout orientation weight.

+4

, , ImageView LinearLayout orientation:

     <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="horizontal"
            android:weightSum="3" >
         <ImageView
                android:id="@+id/login_button"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/login_non_click" />
         <ImageView
                android:id="@+id/comapre_now_button"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/compare_now_non_click_state" />
         <ImageView
                android:id="@+id/search_button"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/search_non_click" />   
        </LinearLayout>
+9

All Articles