Change background color to a limited area of a view - Android

拥有回忆 提交于 2019-12-04 22:13:27

I solved it with inverse fill path

private void drawBlackBackgorund() {
    int x = width / 6;
    int y = height / 4;
    int widthLength = x*5;
    int heightLenght = y* 3;

    RectF rect = new RectF(x,y,widthLength,heightLenght);

    path.addRect(rect,Path.Direction.CW);
    path.setFillType(Path.FillType.INVERSE_EVEN_ODD);
    canvas.clipPath(path);
    canvas.drawColor(getResources().getColor(R.color.black60));

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!