如何将相对布局放置在屏幕底部(或线性布局)。
有以下我想把第二线性布局在屏幕的底部。 我该怎么办? 我有第二个相对布局属性设置为底部,但底部处仍然没有显示..
**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RelativeLayout>
<RelativeLayout android:id="@+id/RelativeLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</RelativeLayout>
<RelativeLayout android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="bottom">
</RelativeLayout>
</LinearLayout>
** Thanx提前
你想在底部的布局应该有:android:gravity = "bottom"
及其母公司应该有:android:layout_height="fill_parent"
我也在寻找这一点。我刚刚找到的解决方案是使用属性:
android:layout_alignParentBottom="true"
,而不是现有的android:layout_gravity="bottom"
这不幸的是我的布局具有附加RelativeLayout
作为根布局时,其余加入到它才会起作用。也许情况并非总是如此,但拥有LinearLayout
(即使在被告知使用fill_parent
时),它只使用所有需要添加的元素的高度,并将其页脚放置在底部。
我来到这个解决方案,寻找此相关的问题:How do I achieve the following result using RelativeLayout?
编辑在这里,因为在回答注释格式迷路了: 你的意思是你不能重写它或者它没有工作?
我也有一个垂直的LinearLayout,我的新XML结构看起来(没有布局大小参数等)。像这样:
<RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout01">
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout02"
android:layout_below="@+id/RelativeLayout01">
</RelativeLayout>
<RelativeLayout
android:layout_below="@+id/RelativeLayout02"
android:layout_alignParentBottom="true">
</RelativeLayout>
</RelativeLayout>
<Linearlayout android:layout_height="fill_parent"
android:orinationtation="vertical"
android:layout_width="fill_parent">
<RelativeLayout android:layout_height="0dp"
android:layout_width="fill_parent"
android:weight="1">
</RelativeLayout>
<RelativeLayout
android:layout_height="0dp"
android:layout_width="fill_parent"
android:weight="1"
>
</RelativeLayout>
</Linearlayout >
你应该把你的浏览最后布局之前,权重为1,它将把它底部。就像这样:
<View android:id="@+id/emptySpace"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
这应该是正确的答案! – 2016-03-10 13:12:21
尝试使用:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffb3e5fc"
android:id="@+id/linearLayout1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<Button
android:id="@+id/button1"
android:text="Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/centerPoint" />
<TextView
android:id="@+id/centerPoint"
android:text=""
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<Button
android:id="@+id/button2"
android:text="Right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/centerPoint" />
</RelativeLayout>
</LinearLayout>
我想把第二相对布局在屏幕 – Sandy 2010-09-27 09:06:52