文本视图中的惯性滚动

6
我有一个充满解析HTML的TextView,内容比手机屏幕还要长,因此我启用了滚动功能,使用方法如下:
tv1.setMovementMethod(new ScrollingMovementMethod());

这个方法可以实现手指直接滚动,但是它没有惯性滚动,就像在网络浏览器、联系人或其他应用程序中发现的那样。我已经搜索了很久,但一直无法找到有关TextView是否具有惯性滚动的信息。


3
不,没有为此目的内置支持。但是你可以通过跟踪TextView上的触摸等来实现它。但是,你不能将那个 TextView 放入一个 ScrollView中吗?那样会给你想要的惯性滚动效果。 - Rajkiran
1个回答

0
<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

<TextView
    android:textColor="@color/textColor"
    android:id="@+id/description"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="20dp"

    android:layout_marginTop="8dp"
    android:layout_marginRight="20dp"
    android:layout_marginBottom="16dp"
    android:fontFamily="@font/merriweather_light"
    android:text=""
    android:textSize="20dp">


</TextView>
</ScrollView>

这对我起作用了。只需将其放在ScrollView块内即可。

(Android Studio 2020.3.1 p3)我必须将TextView的“layout_height”设置为“wrap_content”。 - duanev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接