Scrollview不会在列表视图的自定义视图中滚动

时间:2016-06-21 15:51:18

标签: android scrollview

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"

    android:layout_height="140dp"
    android:background="@color/colorPrimary">


    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/image"
        android:layout_centerHorizontal="true"
        android:fillViewport="true"
        android:scrollbars="vertical"

        >


        <TextView
            android:id="@+id/prayerMessage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="please God forgive me for all my mistakes i have ever done in my life please God forgive me for all my mistakes i have ever"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#ffffff"

            />

    </ScrollView>
</RelativeLayout>

这是我的xml文件,而scrollview没有滚动。

有人可以建议一个解决方案吗?

我使用自定义适配器

为列表视图使用自定义视图

2 个答案:

答案 0 :(得分:1)

不建议在彼此内部使用多个Scrollable视图。您在列表视图中使用ScrollView,而您不应该这样做。这是一种不好的做法。

而是使用动态布局添加 view.add()

答案 1 :(得分:0)

滚动视图的高度为200dp。由于200dp适合屏幕,因此无需滚动。您可以尝试将高度设置为

android:layout_height="match_parent"

android:layout_height="wrap_content"

如果您的UI项目的高度大于屏幕尺寸。