문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top