Android Tag/Badge Widget With Material Chip

Enable Android Enable Material Design.

<com.google.android.material.chip.Chip
    android:id="@+id/batchStatusChip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Success"
    />

Change color

<com.google.android.material.chip.Chip
    android:id="@+id/batchStatusChip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Success"
    android:layout_gravity="right"
    app:chipBackgroundColor="@color/success_chip"
    android:textColor="@android:color/white"
    />

Change color programatically

batchStatusChip.chipBackgroundColor = getColorStateList(context, R.color.success_chip)

res/values/colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="success_chip">#01DF3A</color>
    <color name="fail_chip">#FA5858</color>
</resources>

NOTE: Refer Android Tag Input/EditText (Material Chips)

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.