我想设置布局高度自动像这样的画面:Android的:如何设置布局高度自动
因为如果我在fill_parent
或match_parent
组布局的高度,它看起来是这样的:
我想要一个像fill_parent
但在中间。
对不起,英文不好,我希望你能理解。
我想设置布局高度自动像这样的画面:Android的:如何设置布局高度自动
因为如果我在fill_parent
或match_parent
组布局的高度,它看起来是这样的:
我想要一个像fill_parent
但在中间。
对不起,英文不好,我希望你能理解。
布局的布局使用重量财产
您可以使用
android:layout_width="wrap_content"
android:layout_height="wrap_content"
自动设置布局按照您的内容
<?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>
你为什么不使用重量为布局? – Raghavendra
设置“Wrapcontent”@Julian Pera – YUVRAJ
您应该使用RelativeLayout作为父项。 –