android textView加边框
16lz
2021-01-23
In android 2.2 you could do the following.
Create an xml drawable such as /res/drawable/textlines.xml and assign this as a TextView's background property.
<TextViewandroid:text="My text with lines above and below"android:background="@drawable/textlines"/>
/res/drawable/textlines.xml
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <stroke android:width="1dp" android:color="#FF000000" /> <solid android:color="#FFDDDDDD" /> </shape> </item> <item android:top="1dp" android:bottom="1dp"> <shape android:shape="rectangle"> <stroke android:width="1dp" android:color="#FFDDDDDD" /> <solid android:color="#00000000" /> </shape> </item></layer-list>
The down side to this is that you have to specify an opaque background colour, as tranparencies wont work. (At least i thought they did but i was mistaken). In the above example you can see that the solid colour of the first shape #FFdddddd is copied in the 2nd shapes stroke colour
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer