This is the top menu, initially it was just on the button and there were no problems, redid it for the land mode and had to redo it. The question is how to swap, what would be the first picture, and below it the text. Here is the code:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <include layout="@layout/title" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/bg_button" android:orientation="horizontal" > <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.2" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="75dp" android:layout_gravity="top" android:orientation="vertical" > <ImageView android:id="@+id/homeButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/ic_home_g" /> </RelativeLayout> <LinearLayout android:id="@+id/homeButtonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView style="@style/buttonFont" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center|bottom" android:text="@string/str_base_activity_toolbar_home" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.2" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="75dp" android:orientation="vertical" > <ImageView android:id="@+id/assignedButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/ic_trailer_inspection_g" /> <TextView android:id="@+id/assignedButtonCounter" style="@style/buttonBadge" android:layout_alignRight="@id/assignedButton" android:layout_alignTop="@id/assignedButton" android:text="2" android:visibility="gone" /> </RelativeLayout> <LinearLayout android:id="@+id/assignedButtonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView style="@style/buttonFont" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/str_base_activity_toolbar_assigned" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.2" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="75dp" android:orientation="vertical" > <ImageView android:id="@+id/availableButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/ic_available_g" /> <TextView android:id="@+id/availableButtonCounter" style="@style/buttonBadge" android:layout_alignRight="@id/availableButton" android:layout_alignTop="@id/availableButton" android:text="2234" android:visibility="gone" /> </RelativeLayout> <LinearLayout android:id="@+id/availableButtonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView style="@style/buttonFont" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/str_base_activity_toolbar_available" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.2" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="75dp" android:orientation="vertical" > <ImageView android:id="@+id/completedButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/ic_completed_g" /> </RelativeLayout> <LinearLayout android:id="@+id/completedButtonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="vertical" > <TextView style="@style/buttonFont" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/str_base_activity_toolbar_completed" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.2" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="75dp" android:layout_gravity="top" android:orientation="vertical" > <ImageView android:id="@+id/mailButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/ic_mail_g" /> <TextView android:id="@+id/mailButtonCounter" style="@style/buttonBadge" android:layout_alignRight="@id/mailButton" android:layout_alignTop="@id/mailButton" android:text="2" android:visibility="gone" /> </RelativeLayout> <LinearLayout android:id="@+id/mailButtonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView style="@style/buttonFont" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/str_base_activity_toolbar_mail" /> </LinearLayout> </RelativeLayout> </LinearLayout> <LinearLayout android:id="@+id/parentLinearLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg_main" android:orientation="vertical" > </LinearLayout> </LinearLayout> 

Here is a piece of code that interests you:

 <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.2" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="75dp" android:orientation="vertical" > <ImageView android:id="@+id/completedButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="centerInside" android:src="@drawable/ic_completed_g" /> </RelativeLayout> <LinearLayout android:id="@+id/completedButtonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="vertical" > <TextView style="@style/buttonFont" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/str_base_activity_toolbar_completed" /> </LinearLayout> </RelativeLayout> 
  • one
    You better code on pastebin.com uploaded. Width is not comfortable to read. - Jakeroid 4:03 pm
  • 2
    +1 to advice. And still show better a problem piece of the code, but not all layout. It would be nice if the picture is there or there is a mocap of what you need to receive and what is obtained at the moment - vitaly_gashock
  • Now there is no possibility to lay out a picture, and I will lay out a piece of code at the bottom of my message - zesen

1 answer 1

Remark - certainly not on topic. RelativeLayout nested in each other is not ice ... RelativeLayout is good in that there is no need to invest them in each other:

It can eliminate nested ViewGroups

Note now on topic. Use the android:layout_below or android:layout_below or android:layout_above . Sticking here

  • Thanks, I will try ... - zesen