Skip to content

Instantly share code, notes, and snippets.

@oligazar
Last active October 24, 2017 01:11
Show Gist options
  • Save oligazar/cc866d55104ee102156dc31d196b1d71 to your computer and use it in GitHub Desktop.
Save oligazar/cc866d55104ee102156dc31d196b1d71 to your computer and use it in GitHub Desktop.
When soft keyboard is present it's impossible to make EditText content scroll. Only with custom textListener that disallows touch event interception.
<android.support.v7.widget.AppCompatEditText
android:id="@+id/etText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_normal"
android:layout_marginLeft="@dimen/spacing_normal"
android:layout_marginRight="@dimen/spacing_normal"
android:layout_marginStart="@dimen/spacing_normal"
android:layout_marginTop="@dimen/spacing_normal"
android:ems="10"
android:hint="@string/hint_text"
android:inputType="text|textMultiLine"
android:overScrollMode="always"
android:maxLines="3"
android:scrollbars="vertical"/>
etText.setOnTouchListener { v, event ->
if (v.id == R.id.etText) {
v.parent.requestDisallowInterceptTouchEvent(true)
when (event.action and MotionEvent.ACTION_MASK) {
MotionEvent.ACTION_UP ->
v.parent.requestDisallowInterceptTouchEvent(false)
}
}
false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment