2010-11-23 244 views
0

可能是這個問題的答案。如果是的話,那麼你能否指出我正確的方向。 我想在我的應用程序中添加平滑的滾動功能。 即我有一個巨大的文字,我想滾動它自動(如書讀者) 任何人都可以提供任何平滑滾動的例子?平滑滾動

感謝

回答

4

只要把你想滾動型內滾動視圖(S)。所以把一些文字滾動區,把文本中一個TextView,然後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> 
+0

感謝Ollie C,我確實像你說過的,我可以滾動文本,並且可以看到滾動條,問題是我該如何自動滾動它。我試圖使用scrollTo和ScrollView.scrollBy和ScrollView.scrollTo方法,但它不適合我。謝謝 – nixspirit 2010-11-24 05:45:20

0

使用反射來更新了滾動的滾輪:

Field mScroller; 
mScroller = ScrollView.class.getDeclaredField("mScroller"); 
mScroller.setAccessible(true); 

CustomScroller scroller = new CustomScroller(getContext(), new AccelerateInterpolator()); 
mScroller.set(this, scroller); 

使用smoothScrollTo方法(可能必須setSmoothScrolligEnabled(true))