在自定义回收站适配器中滚动文本视图

时间:2018-08-27 12:26:38

标签: android android-recyclerview textview scrollview

我正在使用带有自定义适配器的自定义RecyclerView。在适配器模型XML内有一个高度和宽度固定的文本视图,我需要在文本视图内滚动文本。滚动文本视图时,请勿滚动整个RecyclerView

2 个答案:

答案 0 :(得分:1)

您可以尝试用TextView包裹NestedScrollView

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    </android.support.v4.widget.NestedScrollView>

答案 1 :(得分:0)

RecyclerView并非为此目的。您想做的就是这样

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="50dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="This is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\nThis is a very very longs text\n"/>
</ScrollView>

如果您坚持在RCV中使用此类TextView,请重新考虑您的设计思想。垂直内部垂直滚动是一个可怕的想法。