效果图:

解决ScrollView与内部嵌套的TextView、EditText的滚动冲突


如果你整体布局是一个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;
    }
});


好了,搞定,完美解决了,效果图所示!

相关文章:

  • 2021-12-09
  • 2021-10-03
  • 2022-12-23
  • 2022-01-03
  • 2021-07-15
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-26
  • 2021-12-31
  • 2021-10-01
  • 2022-01-08
  • 2022-12-23
相关资源
相似解决方案