【问题标题】:TextInputLayout - Cursor doesn't follow user typing at the end of the viewTextInputLayout - 光标不跟随用户在视图末尾输入
【发布时间】:2020-01-28 04:19:46
【问题描述】:

说明:

用户开始输入长文本,当光标“击中”视图末尾时,EditText 不会水平滚动,并且用户在此之后输入的所有字母都不会显示。要查看输入的文本,用户需要手动滚动 EditText。

换句话说,光标没有跟随用户正常输入的文本的末尾。

源代码:

关于 XML:

<com.google.android.material.textfield.TextInputLayout android:id="@+id/tilEmail"
        android:layout_width="0dp"
        android:layout_height="wrap_content">
        <EditText android:id="@+id/etEmail"
            android:inputType="textEmailAddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>

毕业了

api 'androidx.legacy:legacy-support-v4:1.0.0'
api 'androidx.appcompat:appcompat:1.1.0'
api 'androidx.core:core-ktx:1.0.2'
api "com.google.android.material:material:1.0.0"

Android API 版本:在 API 28 上测试

设备: Pixel 3

更新

当我将属性 android:scrollbars="vertical" 放在我的 EditText 上时,我发现问题已部分解决。

“部分解决”,因为当我在具有android:windowSoftInputMode="adjustPan" 的活动中使用它时,问题不断发生。

【问题讨论】:

  • 这方面有什么更新吗? @路易斯

标签: android android-textinputlayout material-components-android android-textinputedittext


【解决方案1】:

使用 TextInputEditText。

试试android: scrollbars="vertical"。 版本api"com.google.android.material: material: 1.0.0"

【讨论】:

  • 这项工作部分解决了我的解决方案,因为当我使用android:windowSoftInputMode="adjustPan" 时,问题不断发生
【解决方案2】:

使用TextInputEditText 而不是EditText

<com.google.android.material.textfield.TextInputLayout
    ...>

    <com.google.android.material.textfield.TextInputEditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          .../>

</com.google.android.material.textfield.TextInputLayout>

自动与layout_height="wrap_content" 内容使用多行。

同时尝试最新版本 1.1.0-alpha10。

【讨论】:

  • 但问题是当我使用android:inputTypeandroid:windowSoftInputMode="adjustPan 时(我会用这些信息更新我的问题)
猜你喜欢
  • 1970-01-01
  • 2013-07-20
  • 1970-01-01
  • 1970-01-01
  • 2020-07-29
  • 2019-08-24
  • 2011-10-25
  • 1970-01-01
  • 2011-11-08
相关资源
最近更新 更多