TextInputLayout和双重的EditText暗示问题 [英] TextInputLayout and EditText double hint issue

查看:433
本文介绍了TextInputLayout和双重的EditText暗示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要设置提示与EditText上(这是在TextInputLayout)的Java。

用于设置提示的 code:

AET =(EditText上)findViewById(R.id.aET);
 aET.setHint(H?);

但即使EditText上的重点是,将显示提示两次(里面的EditText也)。

请让我知道,如果有人遇到和发现了一些解决办法

当EDITTEXT的重点是...

当不集中EDITTEXT ..

修改[10日2015年7月]:

 < android.support.design.widget.TextInputLayout
     机器人:ID =@ + ID / ATIL
     机器人:layout_width =match_parent
     机器人:layout_height =WRAP_CONTENT>
     <的EditText
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:ID =@ + ID / AET/>
< /android.support.design.widget.TextInputLayout>


解决方案

我找到了解决办法!

在您添加的EditText

 的android:textColorHint =@机器人:彩色/透明

而在code设置提示从EditText上

  aET.setHint(H ​​+);

在您的EDITTEXT提示是隐藏的,显示从TextInputLayout提示。

编辑:

其他解决方案(最好的)

更新Graddle与Android的新版本:设计

 编译com.android.support:design:22.2.1

I want to set the hint with java in EditText(which is in TextInputLayout).

Code used for setting hint:

aET = (EditText) findViewById(R.id.aET); aET.setHint("h?");

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

when editText is focused...

when editText is not focused..

EDIT[10th July 2015]:

<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>

解决方案

I found the solution !

In your EditText add

android:textColorHint="@android:color/transparent"

And in the code set the hint from the EditText

aET.setHint("h?");

The hint in your editText is hidden and the hint from the TextInputLayout is shown.

EDIT :

Other solution (The best)

Update Graddle with the new version of android:design

compile 'com.android.support:design:22.2.1'

这篇关于TextInputLayout和双重的EditText暗示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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