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 双提示问题
基础教程推荐
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
