I've seen this subject about puting a border around an android textview, and I used it. But now, I would like to put a border around widgets which are situated into a relative layout. How can I do it?
相关问题
- 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
Though all the provided answers work,they are very rigid.what if you want to customise border color,borderthickness for different screens. for that you should try my solution.We are going to follow three steps in creating a custom RelativeLayout that allow you to provide borderColor and Thickness for bottom border.
1)Create a class that extends RelativeLayout and override on Draw method
2)Define stylable properties in attrs.xml
3) you are done and you can use it like
Create a FrameLayout that gets the background color of your border, and a margin or padding of your border width, and place that FrameLayout in your RelativeLayout. Place the TextView in your FrameLayout instead of directly in the RelativeLayout. poof instant border.
res/drawable
folder, create a new filebackground_border.xml
In this file, you will define the background for widget like this:
eg. if you want to put your border on a relativelayout: