ScrollTo, scrollBy, smoothScrollTo, smoothScrollTo does not work in ScrollView after adding a view to the child layout

I have a HorizontalScrollView with a child layout inside. After adding the view to the child layout, I cannot scroll the HorizontalScrollView to the right side of the scroller.

scrollTo, scrollBy, smoothScrollTo, smoothScrollTo does not work.

+7
source share
1 answer

resolved:

LinearLayout ll = (LinearLayout) findViewById(R.id.ll); final HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.hsv); OnGlobalLayoutListener listener = new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { hsv.scrollTo(100, 0); } }; ll.getViewTreeObserver().addOnGlobalLayoutListener(listener); 
+14
source

All Articles