Android TextView With Rounded Corner and Border

Jul 20, 2019

Create res/drawable/share_rounded_corner_with_border.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#D8FFA2"/>

    <stroke android:width="1.5dp"
            android:color="#cf975d"
        />

    <corners android:bottomRightRadius="8dp"
             android:bottomLeftRadius="8dp"
             android:topLeftRadius="8dp"
             android:topRightRadius="8dp"/>
</shape>

NOTE: solid is background and stroke is the border.

Usage

<TextView
    android:text="100"
    android:textColor="#ae9450"
    android:padding="2dp"
    android:layout_width="44dp"
    android:layout_height="16dp"
    android:gravity="center"
    android:background="@drawable/share_rounded_corner_with_border"
    />

❤️ 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.