How to make a rectangle with inverted rounded corners?
Based on: https://stackoverflow.com/a/36764393/1268507
Try with custom view:
public class CustomView extends View {
private Path mPath = new Path();
public CustomView(Context context) {
super(context);
}
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
mPath.reset();
mPath.addRoundRect(0, 0, getWidth(), getHeight(), 1000, 1000, Path.Direction.CW);
mPath.setFillType(Path.FillType.INVERSE_EVEN_ODD);
canvas.clipPath(mPath);
canvas.drawColor(Color.parseColor("#FF0000"));
}
}
Not proper way, but will get the result, try
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<padding
android:bottom="-100dp"
android:left="-100dp"
android:right="-100dp"
android:top="-100dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="200dp" />
<stroke
android:width="100dp"
android:color="#FF0000" />
</shape>
</item>
</layer-list>