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 don't work.
In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it. A ScrollView supports Vertical scrolling only, so in order to create a horizontally scrollable view, HorizontalScrollView is used.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With