How can I set a border for an ImageView
and change its color in Android?
相关问题
- 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
This is an old post I know, but I thought this might possibly help someone out there.
If you want to simulate a translucent border that doesn't overlap the shape's "solid" color, then use this in your xml. Note that I don't use the "stroke" tag here at all as it seems to always overlap the actual drawn shape.
Following is my simplest solution to this lengthy trouble.
In the following answer I've explained it well enough, please have a look at that too!
I hope this will be helpful to someone else out there!
Add a background Drawable like res/drawables/background.xml:
Update the ImageView background in res/layout/foo.xml:
Exclude the ImageView padding if you want the src to draw over the background.
I set the below xml to the background of the Image View as Drawable. It works.
And then add
android:background="@drawable/yourXmlFileName"
to yourImageView
I found it so much easier to do this:
1) Edit the frame to have the content inside (with 9patch tool).
2) Place the
ImageView
inside aLinearlayout
, and set the frame background or colour you want as the background of theLinearlayout
. As you set the frame to have the content inside itself, yourImageView
will be inside the frame (right where you set the content with the 9patch tool).In the same xml I have used next: