我有一个底部工作表对话框,并且在布局中存在 EditText.EditText 是多行的,最大行数是 3.我放了:
I have a bottom sheet dialog and exists EditText in layout. EditText is multiline, max lines is 3. I put :
commentET.setMovementMethod(new ScrollingMovementMethod());
commentET.setScroller(new Scroller(bottomSheetBlock.getContext()));
commentET.setVerticalScrollBarEnabled(true);
但是当用户开始垂直滚动 EditText 的文本时,BottomSheetBehavior 拦截事件并且 EditText 不会垂直滚动.
but when user will begin scrolling text of EditText vertically BottomSheetBehavior intercept event and EditText will not scroll vertically.
有人知道如何解决这个问题吗?
Anybody know how to solve this problem?
这是一个简单的方法.
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;
}
});
这篇关于Android:BottomSheetDialog内的多行文本EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!