解决scrollView中嵌套编辑框导致不能上下滑动的问题

EditText设置maxLines之后,文本行数超过maxLines,会网上折叠,上下滑动能够浏览全部文本。

若EditText外层有scrollView。在EditText上下滑动,不会像正常情况那样上。仅仅会滑动了scrollView。

解决的方法是:


mEt_content.setOnTouchListener(this); // 解决scrollView中嵌套EditText导致不能上下滑动的问题

@Override
public boolean onTouch(View v, MotionEvent event) {
	switch (v.getId()) {
	case R.id.et_content:
	case R.id.et_title:
		// 解决scrollView中嵌套EditText导致不能上下滑动的问题
		v.getParent().requestDisallowInterceptTouchEvent(true);
		switch (event.getAction() & MotionEvent.ACTION_MASK) {
		case MotionEvent.ACTION_UP:
			v.getParent().requestDisallowInterceptTouchEvent(false);
			break;
		}
	}
	return false;
}

猜你喜欢

转载自www.cnblogs.com/ldxsuanfa/p/9967502.html