gpt4 book ai didi

android - 如何在 Paint android 应用程序中应用带点的画笔颜色?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:57:04 26 4
gpt4 key购买 nike

当用户点击红色等特定颜色时,我使用以下代码应用字体颜色。

mPaint.setColor(getResources().getColor(R.color.color2));

color.xml文件中的color2是

<color name="color2">#FF3C00</color>

现在我在应用以下颜色时遇到问题。

RED COLOR WITH WHITE DOTS

我在我的应用程序中使用 Canvas 在触摸它时绘制油漆,我想在 Canvas 上绘制类似附加屏幕的东西。我能画出来,但它看起来像纯色(我的意思是完整的圆圈,而不是里面的点)

请帮我找到这个。

最佳答案

您可以使用 BitmapShader为了实现这一点..

这是示例代码。试试这个代码,我希望它能工作。

Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.shader);  
//Initialize the BitmapShader with the Bitmap object and set the texture tile mode
BitmapShader mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

fillPaint.setStyle(Paint.Style.FILL);
//Assign the 'fillBMPshader' to this paint
fillPaint.setShader(mBitmapShader);

//Draw the fill of any shape you want, using the paint object.
canvas.drawCircle(posX, posY, 100, fillPaint);

关于android - 如何在 Paint android 应用程序中应用带点的画笔颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16228985/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com