I'm working right now in order to disable horizontal scrolling of horizontalscrollview (id: ordermenu) which has scrollview(i mean vertical scrollview. id of scrollview's child relativelayout: category01layout, category02layout, ...) as children.
Here is what it looks like in XML:
HorizontalScrollView(ordermenu)
- LinearLayout
- ScrollView
- RelativeLayout(category01layout)
- ScrollView
- RelativeLayout(category02layout)
...
- ScrollView
- RelativeLayout(category08layout)
The screen shows one category layout at a time, and when I press prev/next button, it sets horizontalscrollview.smoothScrollTo() to change the category layout.
So when I run the app and scroll, my finger is scrolling both HorizontalScrollView and ScrollView. But I don't want my finger to make both these two listen the onScrollChanged. I only want ScrollView to listen to my finger to 'only scroll vertically'. Since I don't know the way to do this, ScrollView scrolls vertically in a smooth way only if I scroll in an exact vertical direction. Otherwise my finger scrolls HorizontalScrollView also, what I didn't expect.
So is there any way to disable horizontal scrolling and only enable vertical scrolling?
I previously used this method (create a class which extends HorizontalScrollView)
@Override
protected void onScrollChanged(int x, int y, intoldx, intoldy){
if(Math.abs(x - oldx) <= 50){
mScrollable = false;
}
else {
mScrollable = false;
}
return;
}
But this just caused a lot of burden for the UI, making vertically scrolling ScrollView too stiff and slow. So please give me another way than this.
Thanks in advance.