Android TextView With Rounded Corner and Border

July 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"
    />
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.