I want to draw rectangle at center of a view like this image .For this I am using the following code
public class TransparentView extends View {
public TransparentView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public TransparentView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TransparentView(Context context) {
super(context);
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
canvas.drawColor(Color.parseColor("#60000000"));
Paint borderPaint = new Paint();
borderPaint.setARGB(255, 255, 128, 0);
borderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setStrokeWidth(4);
Paint innerPaint = new Paint();
innerPaint.setARGB(0, 0, 0, 0);
innerPaint.setAlpha(0);
innerPaint.setStyle(Paint.Style.FILL);
RectF drawRect = new RectF();
drawRect.set(100, 100, 100,100);
canvas.drawRect(drawRect, innerPaint);
canvas.drawRect(drawRect, borderPaint);
}
}
How can i make complete transparent inside the rectangle and poor transparent at the outer region?