我总是随着图书馆的更新而更新,这就是它的结果。
在 build.gradle(Project:xxx) 中:
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
在 build.gradle(Module:app) 中
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
然后把密码字段如下:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
Taadaa...我的密码字段现在如下所示:
您也可以简单地使用 EditText
。
但是,此更新中存在一些问题。
问题: 如果我在 EditText 中放置任何 drawableRight,它什么也不显示。 TextInputLayout 还具有禁用切换功能的属性。我也这样做了,如下所示,但没有成功:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@drawable/ic_alarm_on_black_24dp"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
谁能帮帮我
最佳答案
我在 https://code.google.com/p/android/issues/detail?id=221002 报告了这个问题.
这是库版本 24.2.0
中的错误,但已在版本 24.2.1
中修复。只需更新如下:
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
关于机器人 : TextInputLayout hides drawableRight of child EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39164224/