Java – via code ScrollView

via code ScrollView… here is a solution to the problem.

via code ScrollView

I want to scroll the View programmatically. So far, I’ve found two possibilities:

  • scrollTo(x,y) : The upper left corner of the View corresponds to the point (x,y) that must be drawn in > view. The problem is that after the call, you can’t manually scroll the View so that it shows something above y or to the left of x.
  • setScrollY(y): Seems like the feature I’m looking for. But it only works for APIs above level 14. My application should use API level 8.

Are there other features that can do what I want to do?

Thank you in advance for taking the time to help me.

Solution

Is your View in a ScrollView? If not, you will need to handle the events yourself to manually ScrollView after setting the scroll position using code. It sounds like you need both manual and programmatic control, so you’ll need to use scroll containers or handle touch events yourself.

Related Problems and Solutions