【问题标题】:Make View Scrollable because hidden text使视图可滚动,因为隐藏文本
【发布时间】: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


【解决方案1】:

尝试添加底部填充

<LinearLayout
            android:padding_bottom="50dp"
            />

【讨论】:

  • 这是一个不错的简单想法。它也可以工作。非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-20
  • 1970-01-01
  • 2011-10-27
相关资源
最近更新 更多