scrollTo,scrollBy,smoothScrollTo,smoothScrollTo不要在滚动型加鉴于子布局的工作后 [英] scrollTo, scrollBy, smoothScrollTo, smoothScrollTo don't work in ScrollView after adding view in child layout
本文介绍了scrollTo,scrollBy,smoothScrollTo,smoothScrollTo不要在滚动型加鉴于子布局的工作后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有HorizontalScrollView里面子布局。添加视图到子布局之后,我不能HorizontalScrollView滚动到右侧滚动条的。
I have HorizontalScrollView with child Layout inside. After adding view into child layout I can't scroll HorizontalScrollView to the right side of scroller.
scrollTo,scrollBy,smoothScrollTo,smoothScrollTo不工作。
scrollTo, scrollBy, smoothScrollTo, smoothScrollTo don't work.
推荐答案
解决:
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);
这篇关于scrollTo,scrollBy,smoothScrollTo,smoothScrollTo不要在滚动型加鉴于子布局的工作后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文