我的应用中有一个浮动的edittext
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/text_input_margin"
android:layout_marginTop="@dimen/text_input_margin">
<EditText
android:id="@+id/email"
style="@style/EditText"
android:layout_width="match_parent"
android:layout_height="@dimen/width_height_6"
android:drawableLeft="@drawable/ic_email"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:nextFocusForward="@+id/password"
android:singleLine="true"
android:textAppearance="?android:textAppearanceSmall" />
</android.support.design.widget.TextInputLayout>
及其风格
<style name="EditText" parent="@android:style/Widget.EditText">
<item name="android:background">@null</item>
<item name="android:paddingLeft">@dimen/margin_padding_3</item>
<item name="android:paddingBottom">@dimen/margin_padding_2</item>
<item name="android:drawablePadding">@dimen/margin_padding_3</item>
<item name="android:textCursorDrawable">@drawable/cursor</item>
<item name="android:textColor">@color/colorPrimary</item>
</style>
现在它的当前行为就像当Edittext
聚焦时标签浮动到顶部并突出显示,现在我想做的就是当用户在Edittext
中输入文本并删除焦点时{{1} }颜色应该更改为不同的颜色并保留该颜色,直到TextInputLayout
文本被删除。