子控件和NestedScrollView滑动冲突

HorizontalBarChart 和NestedScrollView滑动冲突

mHorizontalBarChart.setOnTouchListener(new View.OnTouchListener() {

    @Override

    public boolean onTouch(View view, MotionEvent event) {

        //触摸的是HorizontalBarChart则将事件交给HorizontalBarChart处理;否则将事件交由其父类处理

        if (view.getId() == R.id.my_horizontal_bar_chart) {

            view.getParent().requestDisallowInterceptTouchEvent(true);

            if (event.getAction() == MotionEvent.ACTION_UP) {

                view.getParent().requestDisallowInterceptTouchEvent(false);

            }

        }

        return false;

    }

});

EditText.和NestedScrollView滑动冲突

mEditText.setOnTouchListener(new View.OnTouchListener() {

    @Override

    public boolean onTouch(View view, MotionEvent event) {

        //触摸的是EditText并且当前EditText可以滚动则将事件交给EditText处理;否则将事件交由其父类处理

        if ((view.getId() == R.id.edit_work_exception && canVerticalScroll(workExceptionEdit))) {

            view.getParent().requestDisallowInterceptTouchEvent(true);

            if (event.getAction() == MotionEvent.ACTION_UP) {

                view.getParent().requestDisallowInterceptTouchEvent(false);

            }

        }

        return false;

    }

});

你可能感兴趣的:(子控件和NestedScrollView滑动冲突)