2012-05-08 76 views
0

我需要使用3個線性佈局或相關佈局佈局或類似佈局來完成圖片佈局。中間的線性佈局必須根據第一個頂部和第三個底部之間的自由空間來調整高度。 底部的ll必須在那裏修好。 enter image description herelinearlayout在兩個線性佈局之間垂直居中

我該怎麼辦?

感謝,馬蒂亞

回答

2
<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"

+0

謝謝,它的工作原理! – pindol

+0

不客氣:)請「接受」答案。 – Jonas

0

使用此

<?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>