根据Android开发人员文档:



但是我不明白这个定义。你们能告诉我简单的术语是android中的着色器吗?另外,“水平颜色范围”是什么意思?

非常感谢。

最佳答案

着色器允许为Paint对象定义应绘制的内容。

例如,您可以使用BitmapShader定义应使用位图进行绘制。例如,这使您可以绘制带有圆角的图像。只需为Paint对象定义一个BitmapShader,然后使用drawRoundRect()方法绘制带有圆角的矩形。

Android平台提供的其他着色器是用于绘制颜色渐变的LinearGradient,RadialGradient和SweepGradient。

要使用着色器,请通过setShader()方法将其分配给您的Paint对象。

如果填充的区域大于“着色器”,则可以通过“着色器”图块模式定义如何填充其余部分。

The Shader.TileMode.CLAMP constant defines that the edge corners should be used to fill the extra space.
The Shader.TileMode.MIRROR constant defines that the image is mirrored.
The Shader.TileMode.REPEAT defines that the image will be repeated.

资料来源:Vogella

10-07 19:17
查看更多