【发布时间】:2018-11-15 18:06:03
【问题描述】:
我有一个 Activity,屏幕上有 2 个垂直布局,右下角有 1-2 个按钮。
根据线性布局的长度,布局中的文本可能对按钮隐藏。因此,我想让 Activity 始终可滚动,以便用户能够向上拖动 LinearLayouts 并阅读文本。
这是一个小可视化:
我尝试了一些我在网上找到的解决方案,但它不起作用:
第一次尝试:
<ConstraintLayout>
<LinearLayout>...</LinearLayout>
<LinearLayout>...</LinearLayout>
<Button>...</Button>
<ConstraintLayout>
第二次尝试:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout>...</LinearLayout>
<LinearLayout>...</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button .... />
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
-
你的 ScrollView 的属性是什么?
-
添加属性
标签: android android-layout scrollable