Android:BottomSheetDialog中的多行文本EditText

mr.*_*fox 5 android scroll android-edittext bottom-sheet

我有一个底部对话框,并在布局中存在EditText.EditText是多行,最大行是3.我把:

commentET.setMovementMethod(new ScrollingMovementMethod());
commentET.setScroller(new Scroller(bottomSheetBlock.getContext()));
commentET.setVerticalScrollBarEnabled(true);
Run Code Online (Sandbox Code Playgroud)

但是当用户将开始垂直滚动EditText文本时,BottomSheetBehavior拦截事件和EditText将不会垂直滚动.

在此输入图像描述

有谁知道如何解决这个问题?

Hen*_*331 9

这是一个简单的方法.

yourEditTextInsideBottomSheet.setOnTouchListener(new OnTouchListener() {
  public boolean onTouch(View v, MotionEvent event) {
        v.getParent().requestDisallowInterceptTouchEvent(true);
        switch (event.getAction() & MotionEvent.ACTION_MASK){
        case MotionEvent.ACTION_UP:
            v.getParent().requestDisallowInterceptTouchEvent(false);
            break;
        }
        return false;
   }
});
Run Code Online (Sandbox Code Playgroud)


Muh*_*que 5

对于那些对Kotlin解决方案感兴趣的人。这里是

editText.setOnTouchListener { v, event ->
    v.parent.requestDisallowInterceptTouchEvent(true)
    when (event.action and MotionEvent.ACTION_MASK) {
        MotionEvent.ACTION_UP -> 
                      v.parent.requestDisallowInterceptTouchEvent(false)
    }
    false
}
Run Code Online (Sandbox Code Playgroud)