Is it possible to draw a border around a textview?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
The simple way is to add a view for your TextView. Example for the bottom border line:
For the other direction borders, please adjust the location of the separator view.
Here is my 'simple' helper class which returns an ImageView with the border. Just drop this in your utils folder, and call it like this:
Here is the code.
This may help you.
Create a border view with the background color as the color of the border and size of your text view. set border view padding as the width of the border. Set text view background color as the color you want for the text view. Now add your text view inside the border view.
You can set a shape drawable (a rectangle) as background for the view.
And rectangle drawable back.xml (put into res/drawable folder):
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.htmlYou can set the border by two methods. One is by drawable and the second is programmatic.
Using Drawable
Programmatic