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"
您可以在专用主题中找到更多详细信息和示例。
热门推荐
7 简短的二胎祝福语
10 简短霸气女儿生日 祝福语
11 祝福语高考小众诗句简短
12 元旦祝福语20秒简短
13 老师过年祝福语大全 简短
14 一生祝福语简短
15 产检祝福语简短霸气
16 朋友店开张祝福语简短
17 生日爱情祝福语大全简短
18 朋友女儿生日祝福语 简短