Kotlin-聚焦editText时,NestedScrollView卡住了

时间:2019-07-16 10:00:52

标签: android kotlin android-edittext focus android-nestedscrollview

我有一个NestedScrollView,其中有多个editTexts。当我专注于editText时,它不会让活动周围滚动,因为editText只是停留在帧的极限(顶部或底部,取决于我的方向) d滚动)。我为此找到了解决方案,但它使我遇到了一个新问题:有时editTexts变得不专心,因为只要我触摸,android就会自动滚动到它们。因此,我必须再次单击以恢复焦点。这是此半解决方案的代码:

private fun scrollChangeListener() {
     editText16.clearFocus()
}

我认为这无关紧要,但这是nesteScrollVieweditTexts之一的代码:

NestedScrollView:

<androidx.core.widget.NestedScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

EditText:

<EditText
      android:id="@+id/editText16"
      android:layout_width="match_parent"
      android:layout_height="40dp"
      android:inputType="numberDecimal|textNoSuggestions"
      android:maxLength="4"
      android:imeOptions="actionNext"
    />

0 个答案:

没有答案
相关问题