2
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <corners android:radius="0dip"/>
    <stroke android:color="@color/pink" android:width="0dip"/>
    <solid android:color="@color/pink"/>
</shape>

I have that shape, which I give it to my TextView resource.

The issue I have: I have one number text and I want to show it inside the oval but the oval turns into an egg, doesn't keep the circle shape.

I am doing a notification badge.

shkschneider
  • 17,833
  • 13
  • 59
  • 112
user3278732
  • 1,694
  • 10
  • 31
  • 67
  • Please have a Look on this ans this might help..! http://stackoverflow.com/questions/10316354/how-to-make-text-view-shape-circle-and-set-different-background-color-based-on-c – Ateeq Ur Rehman Jan 21 '15 at 10:46
  • Did you define the size of your TextView ? It should be a square if you want the background to have a circle shape. – lcw_gg Jan 21 '15 at 10:48

1 Answers1

5

Just define new drawable with rounded corners and set it as background of your textView

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <solid
                android:color="#70c656" />
            <stroke
                android:width="1dp"
                android:color="#53933f" />
            <corners
                android:radius="8dp" />
            <padding
                android:left="10dp"
                android:top="5dp"
                android:right="10dp"
                android:bottom="5dp" />
        </shape>
    </item>
</selector>

You can also implemet it using 9patch graphics enter image description here

Sergey Pekar
  • 8,555
  • 7
  • 47
  • 54