Android中滚动视图中的滚动视图
问题描述:
我在scrollview中有一个scrollview.xml就是这样
I have a scrollview inside a scrollview . The xml is like this
<RelativeLayout ....
<ScrollView.....
<RelativeLayout ....
<Button.....
<Button ....
<ScrollView
<RelativeLayout ....
..........
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
在第二个滚动视图中滚动不流畅.可以为此提供解决方案.我尝试了互联网上提供的许多解决方案,但没有用.
in this second scrollview in not scrolling smoothly. can give a solution for that. I tried a lot of solution given in the internet but not working.
答
尝试此代码.它对我有用`
Try this code. It is working for me`
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
// Disallow the touch request for parent scroll on touch of
// child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});`