Android draw circle around Text

后端 未结 2 1291
北荒
北荒 2020-12-06 00:43

I have a textView with a single character in it (all single digit, numbers 0-9). I\'d like to draw a circle or a square around the number. I saw a thread mention using a nin

相关标签:
2条回答
  • 2020-12-06 01:29

    You should be able to just give that TextView a Shape drawable that is a circle as a background.

    http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

    0 讨论(0)
  • 2020-12-06 01:41

    Just need to create a round drawable like this

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

    And set this drawable as your TextView background.

    0 讨论(0)
提交回复
热议问题