如何把一个边框一个Android的TextView [英] how to put a border around an android textview

查看:162
本文介绍了如何把一个边框一个Android的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能周围画一个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为纯色有一个透明的背景。 您还可以使用填充,以分离边界的文本。 有关详细信息,请参见:<一href="http://developer.android.com/guide/topics/resources/drawable-resource.html">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

这篇关于如何把一个边框一个Android的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆