2016-01-20 42 views
-1

我想设置布局高度自动像这样的画面:Android的:如何设置布局高度自动

http://i.stack.imgur.com/i7NOx.png

因为如果我在fill_parentmatch_parent组布局的高度,它看起来是这样的:

enter image description here

我想要一个像fill_parent但在中间。

对不起,英文不好,我希望你能理解。

+0

你为什么不使用重量为布局? – Raghavendra

+0

设置“Wrapcontent”@Julian Pera – YUVRAJ

+0

您应该使用RelativeLayout作为父项。 –

回答

0

您可以使用

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 

自动设置布局按照您的内容

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

    <LinearLayout 
     android:id="@+id/aa" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="20dp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="20dp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="20dp" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/bb" 
     android:layout_below="@+id/aa"></LinearLayout> 

    <LinearLayout 
     android:id="@+id/bb" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="20dp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="20dp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="20dp" /> 
    </LinearLayout> 

</RelativeLayout> 
相关问题