简体   繁体   English

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

[英]Scrollview is not scrolling inside a custom view for a listview

<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>

this is my xml file and scrollview is not scrolling. 这是我的xml文件,scrollview没有滚动。

Can anyone please suggest a solution? 有人可以提出解决方案吗?

I am using a custom view for a listview using a custom adapter 我正在使用自定义适配器将自定义视图用于列表视图

It is not recommended to use multiple Scrollable view inside one another. 不建议在彼此之间使用多个Scrollable视图。 You are using ScrollView inside List View and that you should not do. 您正在列表视图内使用ScrollView,但不应这样做。 It is a bad practice. 这是一个坏习惯。

Instead you use Dynamic Layout Addition via view.add() 相反,您可以通过view.add()使用动态布局添加

Height of your scroll view is 200dp. 滚动视图的高度为200dp。 Since 200dp fits in the screen there is nothing to scroll. 由于屏幕可容纳200dp,因此没有任何可滚动的内容。 You can try setting the height to 您可以尝试将高度设置为

android:layout_height="match_parent"

or 要么

android:layout_height="wrap_content"

if height of your UI items are larger then screen size. 如果UI项的高度大于屏幕尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM