Has anyone come across this? There is such a markup

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/root_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" > <!-- top bar --> <RelativeLayout android:id="@+id/top_bar" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentTop="true" android:background="@drawable/topbar_bg" > <TextView android:id="@+id/diafilm_title" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center" android:text="Test Test" android:textColor="#ffffff" android:textSize="17sp" /> <Button android:id="@+id/share_butt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/share_selector" /> <Button android:id="@+id/bookmarks_butt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bookmark_selector" /> <Button android:id="@+id/sett_butt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/settings_selector" /> <ImageView android:layout_width="wrap_content" android:layout_height="match_parent" android:src="@drawable/divider" /> <Button android:id="@+id/prev_butt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:background="@drawable/prev_selector" /> <Button android:id="@+id/play_butt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:background="@drawable/play_selector" /> <Button android:id="@+id/next_butt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:background="@drawable/next_selector" /> </RelativeLayout> <!-- content --> <RelativeLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below=" @id /top_bar" android:layout_margin="2dp" > <FrameLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" > <ru.diafilm.CustomGallery android:id="@+id/screen_img" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#060405" android:spacing="80dp" android:src="@drawable/background" /> <View android:id="@+id/invisible_view" android:layout_width="75dp" android:layout_height="75dp" android:layout_gravity="center" /> </FrameLayout> <LinearLayout android:id="@+id/slides_bar" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:text="@string/slides_text" android:textColor="#000000" /> <GridView android:id="@+id/slides_grid" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="6" android:columnWidth="90dp" android:gravity="center" android:horizontalSpacing="10dp" android:numColumns="1" android:stretchMode="columnWidth" android:verticalSpacing="10dp" /> </LinearLayout> </RelativeLayout> </RelativeLayout> 

The problem is that in spite of the specified attribute in the bottom android: layout_below = " @id / top_bar", the top layout occupies the entire screen.

  • Try playing with scales from top_bar and content - RomanoO
  • Weight does not work in RelativeLayout - DroidAlex
  • so the root can be LinearLayout put - RomanoO
  • From this, nothing will change. It should work without scales. - DroidAlex


1 answer 1

It is not recommended to put RelativeLayout into each other and generally to invest into RelativeLayout in general, for the documentation says:

It can eliminate nested ViewGroups. If you find yourself with a single RelativeLayout.

In Russian, this means that you have a problem with the design of the page - because RelativeLayout is just a tool for removing the ViewGroup nesting.

Remove fsenafik and smoke / drink some coffee and write your layout again.

  • Nice of course, but there is no clear limit on the creation of such a page. Take advice, thank you. - DroidAlex
  • Take away Relative to Relative for starters - this is absolutely absolutely superfluous - Barmaley
  • Any idea how to design this page so that the top topbar and content are in RelativeLayout each? This is necessary in order for the layout to remain at the same resolution at different resolutions, or rather at the same time, the graphic elements and their position. Put the button on the right with the background, it will be on the right at any resolution with the same background. When using weights (proportions) graphic elements will stretch. - DroidAlex