Chi*_*rag 28
请在主布局下选择一个相对布局.将其高度和宽度设置为填充父级,并将其重力设置为底部,并将任何textview或任何按钮放入其中.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Bottom Gravity" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Without Gravity" />
</LinearLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

这取决于您使用的布局.
在RelativeLayout上有
android:layout_alignParentBottom="true"
Run Code Online (Sandbox Code Playgroud)
在LinearLayout上,将其放在底部,并确保正确设置元素layout_weight.
此外,检查财产
android:layout_gravity
Run Code Online (Sandbox Code Playgroud)
并注意到它不同于
android:gravity
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45709 次 |
| 最近记录: |