TextInputLayout and EditText double hint issue(TextInputLayout 和 EditText 双提示问题)
问题描述
我想在 EditText(在 TextInputLayout 中)中用 java 设置提示.
I want to set the hint with java in EditText(which is in TextInputLayout).
用于设置提示的代码:
aET = (EditText) findViewById(R.id.aET);aET.setHint("h?");
但是即使edittext被聚焦,Hint也会显示两次(也在edittext内部).
But even when edittext is focused, Hint is displayed twice(inside edittext also).
如果有人遇到过并找到解决方法,请告诉我
Please let me know if anyone had faced and found some workaround
editText 聚焦时...
editText 未聚焦时..
编辑[2015 年 7 月 10 日]:
<android.support.design.widget.TextInputLayout
android:id="@+id/aTIL"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/aET" />
</android.support.design.widget.TextInputLayout>
推荐答案
我找到了解决方案!
在你的 EditText 中添加
In your EditText add
android:textColorHint="@android:color/transparent"
并在代码中设置来自 EditText 的提示
And in the code set the hint from the EditText
aET.setHint("h?");
editText 中的提示被隐藏,TextInputLayout 中的提示被显示.
The hint in your editText is hidden and the hint from the TextInputLayout is shown.
其他解决方案(最佳)
使用新版本的 android:design 更新 Gradle
Update Graddle with the new version of android:design
compile 'com.android.support:design:22.2.1'
这篇关于TextInputLayout 和 EditText 双提示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:TextInputLayout 和 EditText 双提示问题
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
