Android中Design库之TextInputLayout、TextInputEditText 发表于 2017-06-23 | 分类于 Android 5.0 | 本文总阅读量 次 时间不会辜负每一个平静努力的人!欢迎来到周建的博客: 共同致力于技术分享与交流 首先上一张效果图: 布局文件 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><android.support.design.widget.TextInputLayoutandroid:id="@+id/text_phone_layout"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="50dp"android:paddingLeft="15dp"android:paddingRight="15dp"android:textColorHint="@color/buttoncolor"app:counterEnabled="true"app:counterMaxLength="11"app:counterTextAppearance="@style/MyStyle"app:counterOverflowTextAppearance="@style/MyOverStyle"><android.support.design.widget.TextInputEditTextandroid:id="@+id/text_phone"android:layout_width="match_parent"android:layout_height="40dp"android:textSize="15sp"android:hint="手机号码"android:inputType="number"android:textColor="@color/buttoncolor"/></android.support.design.widget.TextInputLayout><android.support.design.widget.TextInputLayoutandroid:id="@+id/text_password_layout"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="40dp"android:paddingLeft="15dp"android:paddingRight="15dp"android:textColorHint="@color/buttoncolor"app:passwordToggleDrawable="@mipmap/eye"app:passwordToggleEnabled="true"app:passwordToggleTint="@color/buttoncolor"app:counterEnabled="true"app:counterMaxLength="6"app:counterTextAppearance="@style/MyStyle"app:counterOverflowTextAppearance="@style/MyOverStyle"><android.support.design.widget.TextInputEditTextandroid:id="@+id/text_password"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="密码"android:textSize="15sp"android:inputType="textPassword"android:singleLine="true"android:textColor="@color/buttoncolor"/></android.support.design.widget.TextInputLayout><Buttonandroid:id="@+id/login"android:layout_width="match_parent"android:layout_height="35dp"android:layout_marginLeft="15dp"android:layout_marginRight="15dp"android:layout_marginTop="50dp"android:background="@color/buttoncolor"android:text="登录"android:textColor="@color/textColor"/></LinearLayout> ###源码下载 源码下载:https://github.com/zeke123/TextInputLayout