如何解决下 TextInputEditText 在打字时不显示文本,仅在完成或下一个操作或点击屏幕任意位置后显示
下面是我的 EditText 代码,
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/username_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:hintEnabled="false"
app:passwordToggleEnabled="false"
app:passwordToggleTint="@color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/login_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_username_input"
android:layout_weight="0.0"
android:drawableEnd="@drawable/password"
android:background="@drawable/round_bg"
android:hint="@string/login_password_hint"
android:imeActionLabel="@string/action_done"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"
android:nextFocusDown="@+id/submit_btn"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:text=""
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textCursorDrawable="@null"
tools:ignore="RtlSymmetry" />
</com.google.android.material.textfield.TextInputLayout>
我正在以编程方式设置密码眼睛图标,如下所示,
passwordLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
passwordLayout.setEndIconDrawable(GetDrawable.getDrawable("Show/Hide Password"));
passwordLayout.setEndIconTintList(ColorStateList.valueOf(getResources().getColor(R.color.color_white)));
这适用于大多数设备。但是在 Mi a2 Android 版本 10 中遇到以下问题。
我有两个 TextInputLayout 用于用户名和密码字段 输入用户名字段时没有问题。 接下来移至密码字段。现在,光标停留在第一个位置,输入文本显示在键盘中,但不显示在 Edittext 字段中。点击屏幕上的其他地方后只显示文本
我不知道为什么在某些设备中会发生这种情况
发现以下与我的问题相关的问题。但是那里没有提供解决方案。
TextInputEditText is not showing the typed text/number when typing
更新
在此给出了针对我的问题的解决方案 Android Pie edittext does not adjustPan/resize while typing,但使用硬件加速可能会导致内存使用率过高。所以害怕使用这个解决方案。 有没有其他办法解决这个问题?
解决方法
我在两台 Android 设备上的模拟器上测试了代码,发现使用 com.google.android.material:material:1.3.0
没有任何问题
- 请更新您的颜色样式,它没有可读性
- pan Adjuesment 相关发出登录调试检查
- 尝试使用 alpha 或 Rc MDC 来解决 libaray 版本错误
- 最后你要做的是在 MDC github here
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。