如何在 Android 文本视图周围放置边框? [英] How do I put a border around an Android textview?
本文介绍了如何在 Android 文本视图周围放置边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 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"/>
和矩形drawable back.xml(放入res/drawable文件夹):
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="@android:color/white" />
<stroke android:width="1dip" android:color="#4fa5d5"/>
</shape>
您可以使用 @android:color/transparent
使纯色具有透明背景.您还可以使用填充将文本与边框分开.有关更多信息,请参阅:http://developer.android.com/guide/主题/资源/drawable-resource.html
You can use @android:color/transparent
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
这篇关于如何在 Android 文本视图周围放置边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文