In my LinearLayout I have two child ViewGroups, basically I want them to take 50% of space each (and it is done), but there is also a possibility that content of one of these ViewGroups is much smaller than 50%, in this case, is there any way to make second view match the remaining space?
Now my layout looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:orientation="horizontal"
android:weightSum="1">
<include layout="@layout/layout1"
android:layout_width="0dip"
android:layout_weight="0.5"
android:layout_height="match_parent" />
<include layout="@layout/layout2"
android:layout_width="0dip"
android:layout_weight="0.5"
android:layout_height="match_parent" />
And what I want to achieve is: one layout wrap_content, but no more than 50%, and the second layout fill remaining space.
Thanks in advance!
Make two layouts inside of your linear layouts,and give each of these a
layout_weightof0.5. Then in each of these put a your view groups with the traitandroid:layout_width="wrap_content". As such –