安卓 : Multi line text EditText inside BottomSheetDialog

标签 android scroll android-edittext bottom-sheet

我有一个 Bottom Sheet 对话框,布局中存在 EditText。 EditText 是多行的,最大行数是 3。我输入:

commentET.setMovementMethod(new ScrollingMovementMethod());
commentET.setScroller(new Scroller(bottomSheetBlock.getContext()));
commentET.setVerticalScrollBarEnabled(true);

但是当用户开始垂直滚动 EditText 的文本时,BottomSheetBehavior 拦截事件并且 EditText 不会垂直滚动。

enter image description here

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

最佳答案

这是一个简单的方法。

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;
   }
});

关于安卓 : Multi line text EditText inside BottomSheetDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40218778/

相关文章:

WPF - 使ListView(GridView)在数据太多时滚动?

android - 自动完成文本字段

android - 用户未保存,SharedPreferences

java - 数组列表大小的内存泄漏

android - Jetpack 撰写 : Detect child item overflow and add more badge

android - 为什么创建 C++11 线程会导致致命信号?

android - Android 版 EditText 中的字母间距

java - Windows 8 64 位上的 Android Studio 找不到 JVD

android - 在android中自动滚动TextView以将文本显示在 View 中

javascript - carouFredSel Slider - 防止在幻灯片滚动时滚动到顶部