scrollTo,scrollBy,smoothScrollTo,smoothScrollTo在子视图中添加视图后不能在ScrollView中工作

我有Horizo​​ntalScrollView里面的子布局。 将视图添加到子布局后,我无法将Horizo​​ntalScrollView滚动到滚动条的右侧。

scrollTo,scrollBy,smoothScrollTo,smoothScrollTo不起作用。

Solutions Collecting From Web of "scrollTo,scrollBy,smoothScrollTo,smoothScrollTo在子视图中添加视图后不能在ScrollView中工作"

解决了:

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);