对齐屏幕下方片段
问题描述:
您好我有放在里面的片段部件的线性布局。我试图让片段显示在屏幕的底部。所以我想它固定在屏幕的底部总是在页面可能在未来的滚动。我怎样才能做到这一点?
Hi I have a linear layout with a fragment widget placed inside it. I'm trying get the fragment to show up on the bottom of the screen. The page may be scrollable in the future so I want it anchored on the bottom of the screen always. How can I achieve this?
答
您必须使用 RelativeLayout的
。事情是这样的:
You must use RelativeLayout
. Something like this:
<?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>