Android 如何使用TextInputLayout
示例
确保将以下依赖项添加到build.gradle依赖项下的应用程序文件中:
compile 'com.android.support:design:25.3.1'
输入值时,将EditText的提示显示为浮动标签。
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/form_username"/>
</android.support.design.widget.TextInputLayout>为了使用TextInputLayout显示密码显示眼睛图标,我们可以使用以下代码:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_current_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/current_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/current_password"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>其中app:passwordToggleEnabled="true"&android:inputType="textPassword"是必需的参数。
app应该使用命名空间xmlns:app="http://schemas.android.com/apk/res-auto"
您可以在专用主题中找到更多详细信息和示例。
热门推荐
10 小朋友得奖祝福语简短
11 奶茶便利贴祝福语简短
12 给女儿生日简短祝福语
13 牛年祝福语简短搞笑的
14 猪年祝福语大全简短的
15 生活老师离别祝福语简短
16 老爸的祝福语简短独特
17 孩子新年祝福语简短精辟
18 对女儿生日祝福语简短