Question

I have a HorizontalScrollView, inside the horizontal I have a linearlayout (orientation=horizontal) with 10 views.

I'm trying to show the horizontalscrollview auto scrolled to a selected view.

I've done this requesting focus from the selected view:

li.setFocusable(true);

The problem is that the view apperas at the right of the screen and I'm trying to show the view centered.

Any idea?

Thanks

Was it helpful?

Solution

You can use smoothScrollTo(int x, int y) method, (x, y) represents the position of selected view, you can calculate it easily: (View.getLeft() + View.getPaddingLeft(), View.getTop()).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top