android:如何将相对布局中的所有项目与屏幕底部对齐
我已经把一个线性布局放在一个相对布局中,我正在尝试将父相对布局与屏幕底部对齐android:如何将相对布局中的所有项目与屏幕底部对齐,android,android-layout,android-linearlayout,android-relativelayout,Android,Android Layout,Android Linearlayout,Android Relativelayout,我已经把一个线性布局放在一个相对布局中,我正在尝试将父相对布局与屏幕底部对齐 <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom"> <TextView android:id="@+id/fruits"
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:id="@+id/fruits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fruits"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16sp"
android:layout_alignParentBottom="true"
android:gravity="bottom">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Message: " />
<EditText
android:id="@+id/message_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
更改此项:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
为此:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom">
更改此选项:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
为此:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom">
使用
android:layout\u alignParentBottom=“true”
检查在项目中运行下面的解决方案
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TextView
android:id="@+id/fruits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fruits"
android:layout_alignTop="@+id/linearLayout2"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16sp"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:id="@+id/linearLayout2">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Message: " />
<EditText
android:id="@+id/message_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
使用
android:layout\u alignParentBottom=“true”
检查在项目中运行下面的解决方案
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TextView
android:id="@+id/fruits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fruits"
android:layout_alignTop="@+id/linearLayout2"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16sp"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:id="@+id/linearLayout2">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Message: " />
<EditText
android:id="@+id/message_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
您需要使用
android:layout\u alignParentBottom=“true”
您需要使用
android:layout\u alignParentBottom=“true”
简单!您必须将父级RelativeLayout的高度从包裹内容更改为匹配父级。因此,它将占据整个版面的高度,并附加到屏幕底部。简单!您必须将父级RelativeLayout的高度从包裹内容更改为匹配父级。因此,它将占据整个版面的高度,并附加到屏幕底部。将layout_Upper属性设置为fruits TextView to bottom LinearLayout
试试这个
将属性上方的布局设置为从文本视图到底部线性布局 试试这个
你能画一张图,把你想要的东西画清楚吗!?我想把这整件事都放在屏幕的底部,你能画张图把事情弄清楚吗!?我希望整个内容都在屏幕的底部我认为属性是针对RelativeLayout的子级的,而不是布局本身为了使该属性工作,它也应该有相对布局作为其父级。我认为该属性是针对RelativeLayout的子级的,不是布局本身,为了使该属性起作用,它也应该将相对布局作为其父级。