Search code examples
androidandroid-edittextandroid-theme

How do I change the color of the blob on an Android EditText view?


I'm trying to style an EditText but can't seem to find the right style for one of the UI elements. I don't even know it's name, which is slowing me down a bit :)

The background for this EditText is going to be my theme's primary color (the dark pink in the picture - I've temporarily changed it to light pink so we can see what's happening in a screenshot).

Unfortunately, the teardrop shaped blob is also the primary color, but I can't find a way to change its color.

My question is

a) What's the teardrop shape called?!

and

b) How do I change its color on this EditText?

Thanks.

EditText showing the cursor and blob


Solution

  • You can change it for all EditText with setting the accent color in AppTheme:

    <style name="AppTheme" parent="Base.Theme.AppCompat.Light">
            <item name="colorPrimary">#FF5722</item>
            <item name="colorAccent">#CDDC39</item>
        </style>
    

    Or just for a single EditText using Theme on your EditText:

    <style name="MyEditText" parent="Theme.AppCompat.Light">
            <item name="colorControlNormal">#FF5722</item>
            <item name="colorControlActivated">#CDDC39</item>
        </style>
    

    After that apply your @style on the EditText:

    <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Hint text"
            android:theme="@style/MyEditText"
            />
    

    Result:

    Result