[英]Options to put corners in Android ImageView
I'm trying to put corners im my ImageView and I find these "workarounds": 我试图在我的ImageView上摆个弯角,发现这些“变通办法”:
1 - Take the Bitmap soure and paint then 1-提取位图并绘画
2 - put a second ImageView on my layout and use shape+corners as its source 2-在我的布局上放置第二个ImageView并使用shape + corners作为其来源
It's not possible take the image view and put a corner around then? 不可能将图像视图放在一个角落然后呢?
In my app i have a List with a lot of ImageView (the Bitmap used in this ImageView's is programmatically) and I want to put corners in every ImageView. 在我的应用程序中,我有一个包含很多ImageView的列表(此ImageView中使用的位图是通过编程方式生成的),并且我想在每个ImageView中添加一些角点。
There is any other option? 还有其他选择吗?
You can create a selector
that contains shape
with rounded corners, and then apply it as the ImageView
's background using xml. 您可以创建一个包含圆角
shape
的selector
,然后使用xml将其应用为ImageView
的背景。
Look at this answers here 在这里看这个答案
You can also do it via code by using PorterDuffXfermode
. 您也可以使用
PorterDuffXfermode
通过代码来PorterDuffXfermode
。 PorterDuffXfermode
uses alpha compositing that will allow you to create and intersection (things of mathematical sets here) between the Canvas
you get from onDraw()
and an off screen Canvas
you will have to create. PorterDuffXfermode
使用Alpha合成,可让您在从onDraw()
获得的Canvas
与将要创建的屏幕外Canvas
之间创建和相交(此处为数学集合的事物)。 You will use one of the PorterDuff.Mode
flags to tell the framework you want to only render the pixels that intersect from the two Bitmaps
in each Canvas
. 您将使用
PorterDuff.Mode
标志之一来告诉框架您只想渲染与每个Canvas
的两个Bitmaps
相交的像素。
More on Alpha Compositing 有关Alpha合成的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.