我有一个线性布局(垂直方向),其中包含两个嵌套的线性布局。线性布局内嵌套布局(垂直) - 确保最后一个嵌套布局显示其内容
- 第一个线性布局具有根据特定活动的上下文动态应用的背景图像。图像几乎占据了整个屏幕的大小
- 第二个线性布局包含两个应该显示在活动底部的复选框(水平方向)。
我的问题是,如何可以确保第二线性布局显示在屏幕的底部,只是示出了它需要,允许第一线性布局来显示多达其背景的最小量尽可能的图像?目前它正在被第一张LL的bg图像推出屏幕。
谢谢。
我有一个线性布局(垂直方向),其中包含两个嵌套的线性布局。线性布局内嵌套布局(垂直) - 确保最后一个嵌套布局显示其内容
我的问题是,如何可以确保第二线性布局显示在屏幕的底部,只是示出了它需要,允许第一线性布局来显示多达其背景的最小量尽可能的图像?目前它正在被第一张LL的bg图像推出屏幕。
谢谢。
使用权,你可以做你想做的:在加权布局
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:orientation="horizontal"
android:background="#FF0000"
android:layout_weight="1"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#00FF00"
android:layout_weight="1"
>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />
</LinearLayout>
</LinearLayout>
<LinearLayout
... >
<LinearLayout
...
android:layout_height="0dp"
android:layout_weight="1"
>
...
</LinearLayout>
<LinearLayout
...
android:layout_height="wrap_content"
>
...
</LinearLayout>
</LinearLayout>
通知,高度设置为“0dp”。只有一个权重,加权的一个将延伸到适合剩余的可用区域。
您可以使用的RelativeLayout作为外布局而不是的LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/bottomLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
...
</LinearLayout>
<LinearLayout
android:id="@+id/topLayout"
android:layout_above="@id/bottomLayout"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
...
</LinearLayout>
</RelativeLayout>