Android的加入边框图像的ImageView [英] Android Add border image to imageview
问题描述
是否有可能增加一个位图作为动态Java中的一个机器人的ImageView的边界?
我已经尝试以下
- 在XML和边界图像视图形状的结果是错了,我想在添加边框位图。
您已经有多个选项:
-
放置一个其他浏览你的ImageView上面的边框(也ImageView的)。大公可能是simples溶液。只需添加另一种观点将XML,并确保他们是重叠的。 (例如使用一个相对或作为的FrameLayout容器)
-
使用一个层列表并绘制位图上方的形状,并添加到您的ImageView
-
编写自定义的ImageView和使用Canvas绘制边框的覆盖的onDraw方法。例如。 canvas.drawRect(...)的pretty简单。
Is it possible to add a bitmap as border of an ImageView in android dynamically in Java?
I have already tried the following
- image view in XML and border as shape the result is wrong I want to add bitmap in border.
You have got multiple options:
Place an other View with the border (also imageview) above your Imageview. Thay might be the simples solution. Just add an other view to your xml and make sure they are overlapping. (Use for example a Relative or FrameLayout as container)
Use a Layer List and draw a shape above a Bitmap and add that to your ImageView
Write a custom ImageView and use the Canvas to draw the Border in the overwritten onDraw method. E.g. canvas.drawRect(...) its pretty straightforward.
这篇关于Android的加入边框图像的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!