[英]Smooth scrolling in Android applications
我想将平滑滚动功能添加到我的应用程序中。 即我有一个巨大的文本,我想自动滚动它(就像在书籍阅读器中一样)。
谁能提供任何平滑滚动的例子?
只需将要滚动的视图放入 ScrollView。 因此,要将一些文本放入滚动区域,请将文本放入 TextView,然后将 TextView 放入 ScrollView,如下所示:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/my_view_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</ScrollView>
使用反射更新 ScrollView 的 Scroller:
Field mScroller;
mScroller = ScrollView.class.getDeclaredField("mScroller");
mScroller.setAccessible(true);
CustomScroller scroller = new CustomScroller(getContext(), new AccelerateInterpolator());
mScroller.set(this, scroller);
使用 smoothScrollTo 方法(可能需要 setSmoothScrolligEnabled(true))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.