アプリケーションにスムーズ スクロール機能を追加したいと考えています。つまり、巨大なテキストがあり、自動的にスクロールしたい (ブック リーダーのように)。
スムーズなスクロールの例を誰か教えてください。
スクロールするビューをScrollView内に配置するだけです。したがって、スクロール領域にテキストを配置するには、テキストをTextViewに配置してから、次のようにScrollView内にTextViewを配置します。
<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) が必要な場合があります)