3

我的应用中有一个浮动的编辑文本

<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并移除焦点时,TextInputLayout颜色应该更改为不同的颜色并保持该颜色直到Edittext文本被移除。

4

0 回答 0