效果图:
如果你整体布局是一个ScrollView,里面嵌套了大的ScrollView的输入框!里面EditText的滚动已经被禁止,那么有什么办法,可以让EditText滚动!
解决方案:
1、设置EditText的滚动条:scrollbars=“vertical”
<EditText android:id="@+id/et_description" android:layout_width="match_parent" android:layout_height="100dp" android:background="@drawable/login_bg" android:gravity="top" android:hint="个人介绍..." android:scrollbars="vertical" android:padding="@dimen/five_dp" android:textSize="@dimen/fourteen_sp"/>
2、设置EditText滚动的方法:
etContent.setMovementMethod(ScrollingMovementMethod.getInstance());
3、设置EditText的触摸监听进行拦截
etContent.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if(motionEvent.getAction()==MotionEvent.ACTION_DOWN){ //通知父控件不要干扰 view.getParent().requestDisallowInterceptTouchEvent(true); } if(motionEvent.getAction()==MotionEvent.ACTION_MOVE){ //通知父控件不要干扰 view.getParent().requestDisallowInterceptTouchEvent(true); } if(motionEvent.getAction()==MotionEvent.ACTION_UP){ view.getParent().requestDisallowInterceptTouchEvent(false); } return false; } });
好了,搞定,完美解决了,效果图所示!