2010-11-23 247 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))