【发布时间】:2020-05-06 16:41:51
【问题描述】:
如果我想将图像设置到任何屏幕的底部,那么我们可以在相对布局中使用android:layout_alignParentBottom="true"。但由于某种原因,我一定会使用 LinearLayout。屏幕中还有其他视图(按钮、图像按钮、列表视图)。我想将图像放在屏幕底部。无论情况如何,用户都可以在屏幕底部看到这个图像视图。如何在 LinearLayout 中实现alignParentBottom="true" 属性。请参阅以下示例 xml。我正在使用 example1.xml,但我想查看并归档 example2.xml
example1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="#ffffff"
android:textColor="#000000"
android:text="I am sunil"
android:gravity="bottom"/>
</LinearLayout>
example2.xml
<
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="#ffffff"
android:textColor="#000000"
android:text="I am sunil"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
谢谢
【问题讨论】:
标签: android