如何把一个边框一个Android的TextView边框、Android、TextView

2023-09-12 21:32:51 作者:- 禽兽大爷,

是否有可能周围画一个TextView边框?

Is it possible to draw a border around a textview?

推荐答案

您可以设置一个形状绘制(矩形)为背景的观点。

You can set a shape drawable (a rectangle) as background for the view.

<TextView android:text="Some text" android:background="@drawable/back"/>

和矩形绘制back.xml(投入RES /绘制文件夹):

And rectangle drawable back.xml (put into res/drawable folder):

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
   <solid android:color="#ffffff" />
   <stroke android:width="1dip" android:color="#4fa5d5"/>
</shape>

您可以使用#00000000为纯色有一个透明的背景。 您还可以使用填充,以分离边界的文本。 有关详细信息,请参见:http://developer.android.com/guide/topics/resources/drawable-resource.html

You can use #00000000 for the solid color to have a transparent background. You can also use padding to separate the text from the border. for more information see: http://developer.android.com/guide/topics/resources/drawable-resource.html

 
精彩推荐
图片推荐