TextInputLayout 和 EditText 双提示问题 [英] TextInputLayout and EditText double hint issue

查看:30
本文介绍了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 双提示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆