Android: Scroller Animation?

前端 未结 4 1305
醉梦人生
醉梦人生 2020-12-23 18:29

I\'m a newbie in Android development, and I would just like to know a little bit about the Scroller widget (android.widget.Scroller). How does it animate the view? Can the A

4条回答
  •  庸人自扰
    2020-12-23 18:47

    Great answer above. Scroller#startScroll(...) indeed works the same way.

    For example, the source for a custom scrolling TextView at: http://bear-polka.blogspot.com/2009/01/scrolltextview-scrolling-textview-for.html

    Sets a Scroller on a TextView using TextView#setScroller(Scroller).

    The source for the SDK's TextView at: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/widget/TextView.java#TextView.0mScroller

    Shows that TextView#setScroller(Scroller) sets a class field which is used in situations like bringPointIntoView(int) where Scroller#scrollTo(int, int, int, int) is called.

    bringPointIntoView() adjusts mScrollX and mScrollY (with some SDK fragmentation code), then calls invalidate(). The point of all this is that mScrollX and mScrollY are used in methods like onPreDraw(...) to affect the position of the drawn contents of the view.

提交回复
热议问题