Android的加入边框图像的ImageView [英] Android Add border image to imageview

查看:479
本文介绍了Android的加入边框图像的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能增加一个位图作为动态Java中的一个机器人的ImageView的边界?

我已经尝试以下


  1. 在XML和边界图像视图形状的结果是错了,我想在添加边框位图。


解决方案

您已经有多个选项:


  1. 放置一个其他浏览你的ImageView上面的边框(也ImageView的)。大公可能是simples溶液。只需添加另一种观点将XML,并确保他们是重叠的。 (例如使用一个相对或作为的FrameLayout容器)


  2. 使用一个层列表并绘制位图上方的形状,并添加到您的ImageView


  3. 编写自定义的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

  1. image view in XML and border as shape the result is wrong I want to add bitmap in border.

解决方案

You have got multiple options:

  1. 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)

  2. Use a Layer List and draw a shape above a Bitmap and add that to your ImageView

  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆