I have a horizontal LinearLayout with three views inside it. Each has its own layout_width set to 0dp, and different weights. They all have the wrap_content parameter for layout_height.
The problem is that when one of them wraps, the others no longer fill the entire LinearLayout height (they have backgrounds, so it looks ugly).
I want all of them to fill in any remaining vertical space in LinearLayout, and also allow them to wrap content if necessary. Basically, I want all of them to have the height of the tallest brother.
I tried setting layout_gravity to "fill" and "fill_vertical", but it does nothing.
Here is an example layout:
<LinearLayout android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/background_dark" android:orientation="horizontal" > <Button android:id="@+id/job" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_margin="1dp" android:layout_weight="4" android:background="@drawable/btn_bkgnd_dark_grey" android:drawableLeft="@drawable/icon_plus" android:onClick="jobPressed" android:padding="5dp" android:text="Add to Job fgh dfhfg " android:textAppearance="@style/rowitem_notes" android:textColor="@android:color/white" /> <ImageButton android:id="@+id/bookmark" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_margin="1dp" android:layout_weight="2" android:background="@drawable/btn_bkgnd_dark_grey" android:onClick="bookmarkPressed" android:padding="5dp" android:src="@drawable/icon_bookmark" /> <Button android:id="@+id/itemDetailsButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="fill" android:layout_margin="1dp" android:layout_weight="4" android:background="@drawable/btn_bkgnd_dark_grey" android:drawableRight="@drawable/icon_info" android:onClick="itemDetailsPressed" android:padding="5dp" android:text="Item Details" android:textAppearance="@style/rowitem_notes" android:textColor="@android:color/white" /> </LinearLayout>
source share