Frage

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

War es hilfreich?

Lösung

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()).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top