scrollTo, scrollBy, smoothScrollTo, smoothScrollTo don't work in ScrollView after adding view in child layout

后端 未结 1 542

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, s

相关标签:
1条回答
  • 2021-02-09 12:36

    solved:

    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);
    
    0 讨论(0)
提交回复
热议问题