我有一个带有单个字符的textView(所有单个数字,数字0-9)。我想在数字周围画一个圆圈或一个正方形。我看到一个线程提到使用九个补丁来围绕它,但我不确定如何做到这一点(或者如果它是最好的方法)。我怎么能围绕数字圈?
由于
答案 0 :(得分:56)
只需创建一个像这样的圆形绘图
<?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>
并将此drawable设置为TextView背景。
答案 1 :(得分:0)
你应该能够给TextView一个Shape drawable,它是一个圆圈作为背景。
http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
答案 2 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke android:color="@color/teal_200" android:width="2dip"/>
<solid android:color="@android:color/transparent"/>
<size
android:width="10dp"
android:height="10dp"
/>
</shape>