相关疑难解决方法(0)

我应该如何在Android中为图像提供圆角?

我想改变我加载的图像有圆角.

您知道的任何提示,教程,最佳实践?

java android image

38
推荐指数
5
解决办法
4万
查看次数

Canvas.clipPath(Path)未按预期剪切

我正在尝试将画布绘制操作剪切成弧形楔形.但是,在将剪切路径设置为画布后,我没有得到预期的结果.

为了说明,这是我正在做的事情:

在此输入图像描述

path.reset();

//Move to point #1
path.moveTo(rect.centerX(), rect.centerY());

//Per the documentation, this will draw a connecting line from the current
//position to the starting position of the arc (at 0 degrees), add the arc
//and my current position now lies at #2.
path.arcTo(rect, 0, -30);

//This should then close the path, finishing back at the center point (#3)
path.close();
Run Code Online (Sandbox Code Playgroud)

这是有效的,当我简单地绘制这个路径(canvas.drawPath(path, paint))时,它会绘制如上所示的楔形.但是,当我将此路径设置为画布的剪切路径并将其绘制到其中时:

//I've tried it with and without the Region.Op parameter
canvas.clipPath(path, Region.Op.REPLACE);
canvas.drawColor(Color.BLUE);
Run Code Online (Sandbox Code Playgroud)

我得到以下结果(仅留下楔形以显示参考):

在此输入图像描述

所以它似乎剪切到了它的边界矩形Path,而不是它 …

android drawing image-clipping android-canvas

19
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×2

android-canvas ×1

drawing ×1

image ×1

image-clipping ×1

java ×1