[英]android create arc rectangle in shape using xml
我试图在具有形状但没有运气的xml中创建这样的矩形,这是否可能或如何透明化此图像,我的意思是它的颜色想要透明,就像我们为任何带有alpha的形状定义颜色然后我们获得透明性,是否存在任何一种方法?
谢谢
通过将剪切区域(在我的情况下为圆形)的颜色与背景颜色相同,可以做到这一点。
在onDraw中:
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.GRAY);
int x = 10;<br>
int y = 10;<br>
int width = 100;<br>
int height = 100;
for (int i = 0; i < mDrawables.length; i++) {
Drawable dr = mDrawables[i];
if (i == 0) {
dr.setBounds(x, y, x + width, y + height);
dr.draw(canvas);
} else {
x = 10 + 75;
y = 10 + 75;
dr.setBounds(x, y, x + 50, y + 50);
dr.draw(canvas);
}
}
canvas.save();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.