Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Paint object为android中的矩形创建阴影';s setShadowLayer方法?_Android_Draw_Paint_Shadow_Drawrectangle - Fatal编程技术网

如何使用Paint object为android中的矩形创建阴影';s setShadowLayer方法?

如何使用Paint object为android中的矩形创建阴影';s setShadowLayer方法?,android,draw,paint,shadow,drawrectangle,Android,Draw,Paint,Shadow,Drawrectangle,我正在使用两个绘制对象创建一个矩形,如上图所示(一个用于填充,一个用于笔划)。我需要为这个矩形创建一个阴影,阴影的模糊半径、颜色、x和y的偏移量应该可以自定义。 Paint对象具有setShadowLayer方法,我可以使用该方法为Paint对象创建阴影。 问题是如何使用setShadowLayer方法为我正在创建的矩形获取阴影。我应该在fillpaint或strokepaint上调用setShadowLayer吗?我在目标的父视图上调用了setClipChildren(false),在stro

我正在使用两个绘制对象创建一个矩形,如上图所示(一个用于填充,一个用于笔划)。我需要为这个矩形创建一个阴影,阴影的模糊半径、颜色、x和y的偏移量应该可以自定义。 Paint对象具有setShadowLayer方法,我可以使用该方法为Paint对象创建阴影。 问题是如何使用setShadowLayer方法为我正在创建的矩形获取阴影。我应该在fillpaint或strokepaint上调用setShadowLayer吗?我在目标的父视图上调用了setClipChildren(false),在strokepaint上调用了setShadowLayer,但没有正确渲染。我需要一个在paint上使用setShadowLayer的简单示例,我可以将其应用到我的代码中

        Paint fillpaint = new Paint(this.getPaint());
        fillpaint.setColor(fillColor);

        Paint strokepaint = new Paint(fillpaint);
        strokepaint.setStyle(Paint.Style.STROKE);
        strokepaint.setStrokeWidth(borderWidth);
        strokepaint.setColor(borderColor);