Android:添加填充底部/顶部后ScrollView不滚动

时间:2017-04-11 18:26:29

标签: android android-fragments android-view android-scrollview android-relativelayout

我有这个垂直funcs[`verify${tab}Tab`](); ,标题,子标题,摘要文本,按钮和页脚。

一切顺利,直到我添加到ScrollView

<ScrollView>

在此之后,即使我看到页脚被切断,页面也不会滚动。有人可以帮我这个吗?感谢!!!!

    android:paddingTop="xxxx"
    android:paddingBottom="xxx"
    android:clipToPadding="false"

我只能发布这样的图片。摘要字符串可能很长,因此我们需要滚动整个页面。

enter image description here

1 个答案:

答案 0 :(得分:0)

试试这个:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillViewport="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    android:paddingTop="16dp"
    android:paddingBottom="16dp"
    android:clipToPadding="false">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="16dp">

        <TextView
            android:id="@+id/header"
            android:text="This is a header"
            android:textSize="32sp"
            android:gravity="center_horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/subheader"
            android:layout_below="@id/header"
            android:text="Sub-header"
            android:textSize="24sp"
            android:gravity="center_horizontal"
            android:letterSpacing="-0.04"
            android:layout_marginTop="16dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/button"
            android:layout_below="@id/subheader"
            android:text="Button"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="16dp"
            android:layout_width="150dp"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/summary"
            android:layout_below="@+id/button"
            android:text="This is summary. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque venenatis ex et elit tempus, lobortis iaculis justo fringilla. Nunc viverra porttitor elit id vestibulum. Phasellus mollis tempor ex, vitae accumsan nulla condimentum sed. Duis ullamcorper velit ut tempor rutrum. Cras vehicula facilisis tempor. Sed ut consequat enim. Aliquam scelerisque aliquet dapibus. Donec varius urna nec leo rhoncus, et suscipit sapien aliquam. Etiam ut eleifend enim, non viverra tellus. Aenean scelerisque dui ac consequat facilisis. Suspendisse augue odio, bibendum ut condimentum id, tristique id sapien. Curabitur lacus eros, consectetur hendrerit leo in, ullamcorper ultrices arcu. Mauris malesuada, ligula lobortis auctor iaculis, mauris eros imperdiet sapien, at vulputate urna quam non nibh. Sed erat mauris, fringilla ac risus sed, varius pulvinar ex."
            android:textSize="16sp"
            android:layout_marginTop="16dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/footer"
            android:layout_below="@id/summary"
            android:text="This is Footer"
            android:textSize="14sp"
            android:textStyle="bold"
            android:gravity="center_horizontal"
            android:layout_marginTop="16dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </RelativeLayout>
</ScrollView>

<强>输出:

enter image description here