n3w*_*3wb 5 user-interface android
嗨,我有一个线性布局,其中放置了一个片段小部件。我正在尝试让片段显示在屏幕底部。该页面将来可能可以滚动,因此我希望它始终锚定在屏幕底部。我怎样才能做到这一点?
您必须使用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>
Run Code Online (Sandbox Code Playgroud)