edittext外层有ScrollView里面可滑动

点击Edittext获取焦点可以改变框的颜色
    android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp">

android:id="@+id/cont_edt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/zihui"
android:gravity="top"
android:padding="10dp"
android:inputType="textMultiLine"
android:scrollbars="vertical"
android:textSize="@dimen/dimen14"
android:background="@drawable/shurukuang_selector" />

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:src="@drawable/dingweihui" />
xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android">

android:drawable="@drawable/kongxinbtn" android:state_pressed="true" />
android:drawable="@drawable/kongxinbtn" android:state_selected="true" />
android:drawable="@drawable/kongxinbtn" android:state_checked="true" />
android:drawable="@drawable/kongxinbtn" android:state_focused="true" />//主要
android:drawable="@drawable/kongxinhuibianbtn" />

kongxinbtn
xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

android:color="#FFFFFF" />






android:width="2px"
android:color="#6d8dff" />

android:radius="5dp" />
kongxinhuibianbtn
xml version= "1.0" encoding= "utf-8" ?>
xmlns: android = "http://schemas.android.com/apk/res/android"
android :shape= "rectangle" >

android :color= "#FFFFFF" />






android :width= "2px"
android :color= "#66000000" />

android :radius= "5dp" />
private void initView() {
cont_edt = (EditText) findViewById(R.id.cont_edt);
cont_edt.setOnTouchListener(this);
}
@Override
public boolean onTouch(View v, MotionEvent event) {//嵌套scrollView
switch (v.getId()) {
case R.id.cont_edt:
// 解决scrollView中嵌套EditText导致不能上下滑动的问题
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
edittext外层有ScrollView里面可滑动_第1张图片

你可能感兴趣的:(edittext外层有ScrollView里面可滑动)