0

I am trying to display some text in a coloured circle, but it is not working properly. This is how I am rendering the text -

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="GO"
    android:background="@drawable/scancircle"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:textColor="#ffffff"
    android:textSize="18dp"
    android:padding="9dp"
    android:onClick="Go"
    />

And this is how scancircle.xml looks like -

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadius="93dp"
    android:thickness="1dp"
    android:useLevel="false"
    >
    <solid android:color="@color/primary" />
    <stroke
        android:width="2dp"
        android:color="@color/txtVwBackground"
        />

    <padding
        android:left="2dp"
        android:right="2dp"
        android:top="2dp"
        android:bottom="2dp"
        />
</shape>   

Even though the preview of scancircle shows the circle correctly, but there is no circle rendered behind the text. Can anyone tell why is this so?

Thanks in advance.

Sam
  • 4,302
  • 12
  • 40
  • 74
  • What do you see? I would say that right now there should be a big circle behind the textview - much larger than the view itself and perhaps not looking like a circle. – AndroidEx May 15 '15 at 21:01
  • It doesn't show anything, just the text. The circle is of dark blue color and shows up on preview on scancircle.xml. – Sam May 15 '15 at 21:06

1 Answers1

0

Well, actually you don't use circle, you use a ring, which has a hole in the middle. In your case this hole is of 93dp radius that makes it bigger than the TextView itself. Thus what you see behind the text is the hole part of the ring, which is transparent.

You may want to use oval shape for the "circle behind the text" effect.

AndroidEx
  • 15,524
  • 9
  • 54
  • 50