2013-04-26 25 views
5

我使用以下代碼在用戶點擊像RED這樣的特殊顏色時應用字體顏色。如何在Paint android應用程序中使用點的刷子顏色?

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

而且COLOR2在color.xml文件

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

現在我面臨的問題,同時應用下列顏色。

RED COLOR WITH WHITE DOTS

我使用畫布上繪製在我的應用程序接觸它的油漆,我想畫的東西就像在畫布上附着屏幕。我能夠繪製它,但它看起來像純色(我的意思是完整的圓圈,但不是點點內)

請幫我找到它。

回答

3

可以使用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); 
+0

謝謝哥們。其作品。 +1 – 2013-04-26 06:50:21

+0

當我使用此代碼時,它只繪製一次,並且不會繪製先前繪製的塗料 – 2016-03-08 07:26:22

相關問題