Problems with Android FrameLayout when overriding onDraw

protected void onDraw(Canvas canvas) {
            float width = canvas.getWidth();
            float height = canvas.getHeight();
            Path path = new Path();
            path.addArc(new RectF(0, 0, width, height), 90, 180);
            canvas.clipPath(path);
            Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setColor(Color.RED);
            canvas.drawRect(new RectF(0, 0, width, height), paint);
}

I use this code to override other views; this is normal (show a semicircle); but when I use this to override FrameLayout, show me the rectangle ?!

Why? How to change it?

+4
source share

All Articles