Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FrameLayout : Fill empty space

I have 3 FrameLayout in my layout, the first and the third have a fixed height (wrap_content of child views).

And I want the second FrameLayout to fill remaining space between the first and the third element.

My XML :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal" >

    <!-- ... childs views with fixed height -->
</FrameLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp" <!-- Fill remaining space -->
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp" >

    <!-- ... childs views with match_parent height -->
</FrameLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <!-- ... childs view with fixed height -->
</FrameLayout>

</LinearLayout>
like image 455
Florian Mac Langlade Avatar asked Oct 16 '25 23:10

Florian Mac Langlade


1 Answers

you can use the layout_weight="1" property for the central FrameLayout, leaving 0dip for the height. It will the take the space left from the other two

like image 189
Blackbelt Avatar answered Oct 19 '25 13:10

Blackbelt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!