1

在我的项目中,我使用 ScrollView 来显示产品列表,每个产品都会有一个子产品。我正在使用 realviewswitcher 来显示子产品。直到这一切正常。问题是当我滚动滚动视图时它滚动良好。但是在使用 realviewswitcher 查看子产品(从左到右滑动列表视图项)时,滚动视图允许滚动。我想在从左向右滑动时禁用滚动视图。只有当我从上到下滑动时,滚动视图才能工作。

我已经尝试使用自定义 ScrollView。但我没有得到预期的结果。我也用 setEnabled(false) 没用。他们还有其他解决方案吗?请告诉我知道

4

1 回答 1

2

try this

it will disable scrolling as you want(vertical/horizontal). Or you can try this:

implements setOnTouchListener for both parent scrollview and child realviewswitcher like this:

parentScrollView= (ScrollView) findViewById(R.id.parentScrollview);
parentScrollView.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
         //Log.v(TAG,"PARENT TOUCH");
         findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
        return false;
        }
    });
childScrollView= (ScrollView) findViewById(R.id.childScrollView);
childScrollView.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
         //Log.v(TAG,"PARENT TOUCH");
         findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(true);
        return false;
    }
});
于 2013-04-08T07:38:36.213 回答