Android在文本周围画圈 [英] Android draw circle around Text
本文介绍了Android在文本周围画圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 textView,其中包含一个字符(所有单个数字,数字 0-9).我想在数字周围画一个圆圈或一个正方形.我看到一个线程提到使用九个补丁来围绕它设置样式,但我不确定如何做到这一点(或者它是否是最好的方法).我怎样才能在数字周围有一个圆圈?
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 nine-patch to style around it, but I'm unsure of how to do this (or if it is the best way to do it). How can I have a circle around the number?
谢谢
推荐答案
只需要像这样创建一个圆形drawable
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>
并将这个drawable设置为你的TextView背景.
And set this drawable as your TextView background.
这篇关于Android在文本周围画圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文