0

I would like to add the smooth scrolling functionality into my application. i.e. I have a huge text and I want to scroll it automatically (like in book readers).

Could anyone offer any examples of smooth scrolling?

2 Answers 2

4

Just put the view(s) you want to scroll inside a ScrollView. So to put some text in a scrolling area, put the text in a TextView, and then the TextView inside a ScrollView, like this:

<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> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Ollie C, I did like you said, I can scroll the text, and I can see scrollbars, the question is how can I scroll it automatically. I'm trying to use scrollTo and ScrollView.scrollBy and ScrollView.scrollTo methods, but it is not working for me. Thanks
Ollie C, Also I added a button and I've tried to use scrollView.smoothScrollTo(0, POSITION); It is working for me but scrooling is to fast, Can I override scrolling (or animation) settings or smth. Thanks
0

Use reflection to update the ScrollView's Scroller:

Field mScroller; mScroller = ScrollView.class.getDeclaredField("mScroller"); mScroller.setAccessible(true); CustomScroller scroller = new CustomScroller(getContext(), new AccelerateInterpolator()); mScroller.set(this, scroller); 

Use smoothScrollTo method (may have to setSmoothScrolligEnabled(true))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.