Reputation: 6284
Is it possible to have an activity scroll down to a certain point when a button is clicked?
I want my activity to behave just like an anchor in a web page.
I have two buttons at the top of the activity, followed by lengthy text aboout each of the buttons. When I click on the button at the top I want the page to scroll down beginning of that button's description.
Is this possible?
Upvotes: 2
Views: 392
Reputation: 22637
So your outer layout is a scroll view?
You can call
View.requestFocus()
Obviously, the view has to be focusable.
The problem with scrollTo(x,y) mentioned above is most likely that you don't know x, y.
Upvotes: 1
Reputation: 4463
Assuming you are using a TextView to display your text, you use the built in scrolling function myTextView.scrollTo(x,y)
. Put it inside your buttons' onClicks and you should be good to go!
http://developer.android.com/reference/android/widget/TextView.html
Upvotes: 1