在将EditText套进NestedScrollView的状况下,EditText输入了多行内容后,没法触摸滚动到第一行ide
在将EditText套进NestedScrollView的状况下,NestedScrollView会拦截消费屏幕的移动触摸事件,致使EditText没法获取移动触摸事件.布局
在activity里写EditText的触摸监听事件spa
private void initScrollHandler(){ mEditOpinionContent.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //canScrollVertically()方法为判断指定方向上是否能够滚动,参数为正数或负数,负数检查向上是否能够滚动,正数为检查向下是否能够滚动 if (mEditOpinionContent.canScrollVertically(1) || mEditOpinionContent.canScrollVertically(-1)){ v.getParent().requestDisallowInterceptTouchEvent(true);//requestDisallowInterceptTouchEvent();要求父类布局不在拦截触摸事件 if (event.getAction() == MotionEvent.ACTION_UP){ //判断是否松开 v.getParent().requestDisallowInterceptTouchEvent(false); //requestDisallowInterceptTouchEvent();让父类布局继续拦截触摸事件 } } return false; } }); }