[英]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.