Alternative to nested weights with LinearLayouts
android, android-layout
Solution
Yes we have the alternative for nested `LinearLayout` `weight` by android's `percent support library`
Code and concept HERE !
GitHub Project HERE !
Consider this simple layout where I have totally avoided weight property of `LinearLayout`
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/fifty_huntv"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#ff7acfff"
android:text="20% - 50%"
android:textColor="@android:color/white"
app:layout_heightPercent="20%"
app:layout_widthPercent="50%" />
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_toRightOf="@id/fifty_huntv"
android:background="#ffff5566"
android:text="80%-50%"
app:layout_heightPercent="80%"
app:layout_widthPercent="50%"
/>
</android.support.percent.PercentRelativeLayout>
Really awesome !!!
Problem
I want to achieve the following: It works with the following layout: ``` <?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="horizontal"> <LinearLayout android:layout_weight="3" android:layout_width="0dp" android:layout_height="fill_parent" android:orientation="vertical" > <fragment android:name="com.bobjohn.DetailsMenuFragment" android:id="@+id/detailsMenuFragment" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="6" /> <fragment android:name="com.bobjohn.SummaryFragment" android:id="@+id/summaryFragment" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_margin="10dp" android:layout_weight="4"/> </LinearLayout> <TextView android:layout_width="0dp" android:layout_weight="7" android:layout_height="fill_parent" android:text="Test Text"/> </LinearLayout> ``` However, I get the warning about nested weights being bad for performance. I understand the error but I don't know how to express this layout in another way. What is the alternative?