简体   繁体   English

linearlayout垂直居中于两个linearlayout之间

[英]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. 我需要做一个像图片中的布局,使用3 linearlayout,或relativelayout或类似的布局。 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. 中间的线性布局必须根据顶部的第一个ll和底部的第三个ll之间的自由空间来调整高度。 The ll at the bottom has to be fixed there. 底部的ll必须固定在那里。 在此输入图像描述

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 这里重要的是第二个布局中的android:layout_weight="1"

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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