app:hintAnimationEnabled=”true” —设置hint过度到左上角显示是否使用动画过度,默认为true,如果设为false则过度非常生硬 app:hintTextAppearance=”” —设置hint的字体样式,值为一个style app:errorTextAppearance=”” —设置错误提示的字体样式 app:counterTextAppearance=”” —设置计数字体的样式 app:counterOverflowTextAppearance=”” —这个api比较有趣,这个触发的时机是达到最大输入字数时候,这时计数的字体样式会变为这里设置的样式 app:counterMaxLength="100"
TextInputLayout textInputLayout = (TextInputLayout) findViewById(R.id.til);
textInputLayout.setCounterEnabled(true);
textInputLayout.setCounterMaxLength(100);
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="128dp"
android:weightSum="1"
app:counterEnabled="true"
app:counterMaxLength="30"
app:hintAnimationEnabled="true"
app:passwordToggleEnabled="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/passWord_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="0.55"
android:drawableLeft="@mipmap/ic_launcher"
android:drawableStart="@mipmap/ic_launcher"
android:hint="@string/hintPassword"
android:inputType="textPassword"
android:textColorHint="@color/secondary_text"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp" />
</android.support.design.widget.TextInputLayout>