更改 Edit Text 下划线的颜色

1、效果图

这里写图片描述

2、代码实现

1)style.xml 里添加自定义的格式

    <style name="MyEditText" parent="Theme.AppCompat.Light" type="text/css">
        <item name="colorControlNormal">@color/color_default_marker</item>
    </style>

2)layout 里面edit 组件引用自定义的格式

···············
<EditText
    android:id="@+id/test_one"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:hint="name:"
    android:theme="@style/MyEditText"/>  //引用定义的theme

        <EditText
            android:id="@+id/test_two"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:hint="age:"/>
            ············

猜你喜欢

转载自blog.csdn.net/qq_27061049/article/details/80580483