RelativeLayout Android的自定义形状
是否可以在relativelayout上创建如下图所示的自定义形状 我已尝试使用以下代码:RelativeLayout Android的自定义形状,android,android-layout,android-relativelayout,android-custom-view,Android,Android Layout,Android Relativelayout,Android Custom View,是否可以在relativelayout上创建如下图所示的自定义形状 我已尝试使用以下代码: @Override protected void onDraw(Canvas canvas) { int w = this.getWidth() - (this.getWidth()/4); int w2 = this.getWidth() - (this.getWidth()/6); int h = this.getHeight(); Point a = new Poi
@Override
protected void onDraw(Canvas canvas) {
int w = this.getWidth() - (this.getWidth()/4);
int w2 = this.getWidth() - (this.getWidth()/6);
int h = this.getHeight();
Point a = new Point(0, 0);
Point b = new Point(w, 0);
Point c = new Point(w2, h);
Point d = new Point(0, h);
Path path = new Path();
path.moveTo(a.x, a.y);
path.lineTo(b.x, b.y);
path.lineTo(c.x, c.y);
path.lineTo(d.x, d.y);
path.lineTo(a.x, a.y);
path.close();
Paint p = new Paint();
p.setColor(Color.WHITE);
canvas.drawPath(path, p);
super.onDraw(canvas);
}
但它不起作用。有什么想法吗
它画了什么吗?是的。。它正在画白色的部分。。我需要的是灰色部分和白色透明剂?有没有可能@Blackbelt为什么不使用图像?这将是我最后一个选择@OsamaAftab。。我试图改变一条路,但无论我改变什么。。它只画白色的部分