[英]linearlayout centered vertically between two linearlayout
我需要做一個像圖片中的布局,使用3 linearlayout,或relativelayout或類似的布局。 中間的線性布局必須根據頂部的第一個ll和底部的第三個ll之間的自由空間來調整高度。 底部的ll必須固定在那里。
我能怎么做?
謝謝,馬蒂亞
<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>
這里重要的是第二個布局中的android:layout_weight="1"
用這個
<?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.