您好,我有一个线性布局,其中放置了一个 fragment 小部件。我正在尝试让 fragment 显示在屏幕底部。该页面将来可能可以滚动,所以我希望它始终固定在屏幕底部。我怎样才能做到这一点?
最佳答案
您必须使用 RelativeLayout
。像这样:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_fragment" >
</ScrollView>
<fragment
android:id="@+id/bottom_fragment"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true" >
</fragment>
</RelativeLayout>
关于android - 在屏幕底部对齐 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18191535/