Pri*_*alj 2 android scrollview
我有一个带有一些视图的 ScrollView。如果 ScrollView 的内容高度小于屏幕高度,我想强制最后一个视图位于底部。我怎么做?
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<View ... />
<View ... />
<View ... />
<View ... /> // this one should be on bottom if LinearLayout's contents don't exceed screen height
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
添加以下代码
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
Run Code Online (Sandbox Code Playgroud)
在按钮视图之前,你想要 linnerLayout 的底部
+
将 LinearLayout 的 layout_height 更改为 match_parent
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Run Code Online (Sandbox Code Playgroud)
+
添加android:fillViewport="true"到滚动视图
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
942 次 |
| 最近记录: |