首页 文章

材质设计 - EditText底线颜色动画

提问于
浏览
2

我'd like to implement the bottom line color animation of EditText in an Android application, just like the Material Design Lite' s Text Field . 我在研究中找不到任何结果(所有结果都与浮动标签有关) . 任何图书馆或其他参考如何制作这些动画?


EDIT

澄清问题,我想要从字段的中间向左侧和右侧扩展的底线动画(不是浮动标签,如何使底线颜色改变,或形成验证) .

您可以在聚焦“文本字段”组件时看到动画,而您看到的任何动画都是我所指的动画 .

谢谢,Humble Potato II

2 回答

  • 0
    You can create XML Layout like this way
        <?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/color_bg"
            android:orientation="vertical">
         <android.support.design.widget.TextInputLayout
                android:id="@+id/tv_user_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_margin="@dimen/common_layout_dimen_10"
                android:textColorHint="@color/color_black">
    
                <EditText
                    android:id="@+id/et_user_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:hint="@string/lbl_name"
                    android:imeOptions="actionNext"
                    android:inputType="textCapWords"
                    android:maxLines="1"
                    android:singleLine="true"
                    android:textColor="@color/color_black"
                    android:textSize="@dimen/common_text_size_20" />
            </android.support.design.widget.TextInputLayout>
        </RelativeLayout>
    
  • 0

    你只需要使用TextInputLayout . 使用this参考 .

相关问题