简体   繁体   中英

linearlayout centered vertically between two linearlayout

I need to do a layout like the one in the picture, using 3 linearlayout, or relativelayout or whatever similar. The linearlayout in the middle has to adapt the height depending on the free space between the first ll one the top and the third ll at the bottom. The ll at the bottom has to be fixed there. 在此输入图像描述

How can I do?

Thanks, Mattia

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


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

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </LinearLayout>

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

    </LinearLayout>

</LinearLayout>

The important thing here is the android:layout_weight="1" in the second layout

Use this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout 
        android:id="@+id/ui_main_header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:orientation="horizontal"/>


    <LinearLayout 
        android:id="@+id/ui_main_footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"/>

    <LinearLayout 
        android:id="@+id/ui_main_center"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

        android:layout_below="@id/ui_main_header"
        android:layout_above="@id/ui_main_footer"

        android:orientation="vertical"/>

</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM