Android’s complex layout is linear and relative

I have to implement the layout as shown in the diagram, and I do not know the best combination to achieve the required design. I'm designing for a 7-inch tablet and I want the design to stretch to 10 " enter image description here

I guess layouts like 1, 2, 3, 4, 5 are LinearLayouts, right?

* What is an activity layout? I tried RelativeLayout, but I could not spread the width between layouts 1 and 2 and 3 (using android: layout_weight)

* I tried the Horzontal LinearLayout for all the activity, but I could not correctly add the header and footer layouts to the main horzontal linear layout

I read the documentation and tutorials, but could not find the key to this complex design, please help.

Also what is the performance result of nested layouts?

Thanks,

+6
source share
3 answers

You can try something like this, and as someone else said, at this level you will not have performance problems

<?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" android:weightSum="1" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.2" android:background="@android:color/holo_orange_light" android:orientation="horizontal" android:weightSum="1" > <View android:id="@+id/view1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="0.2" android:background="@android:color/black" /> <View android:id="@+id/view2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="0.8" android:background="@android:color/black" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.6" android:background="@android:color/holo_blue_light" android:orientation="horizontal" android:weightSum="1" > <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="0.2" android:background="@android:color/holo_purple" android:orientation="vertical" android:weightSum="1" > <View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.2" android:background="@android:color/black" /> <View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.3" android:background="@android:color/black" /> <View android:id="@+id/view2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@android:color/black" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="0.4" android:background="@android:color/holo_red_dark" android:orientation="vertical" android:weightSum="1" > <View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.33" android:background="@android:color/black" /> <View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.33" android:background="@android:color/black" /> <View android:id="@+id/view2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.33" android:background="@android:color/black" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="0.4" android:background="@android:color/darker_gray" android:orientation="vertical" android:weightSum="1" > <View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@android:color/black" /> <View android:id="@+id/view2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@android:color/black" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.2" android:background="@android:color/holo_green_light" android:orientation="horizontal" android:weightSum="1" > <View android:id="@+id/view1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="0.2" android:background="@android:color/black" /> <View android:id="@+id/view1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="0.3" android:background="@android:color/black" /> <View android:id="@+id/view2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="0.5" android:background="@android:color/black" /> </LinearLayout> </LinearLayout> 

enter image description here

+14
source

You will have a combination of linear and relative layouts. To group blocks horizontally and vertically, you can use LinearLayout, and to place these groups you can either use a linear layout, adjust the weight accordingly, or use a relative one and set them relative to each other.

+1
source

Source: https://habr.com/ru/post/955053/


All Articles