Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply brush color with dots in Paint android application?

Tags:

android

paint

I am using following code to apply font color when user click on perticular color like RED.

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

And color2 in color.xml file is

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

Now I am facing problem while applying following color.

RED COLOR WITH WHITE DOTS

I using canvas to draw paint on touching it in my application and i want to draw something like attached screen on canvas. I am able to draw it but It looks like solid color (I mean full circle but not dot dot inside)

Please help me to find this.

like image 266
Hardik Joshi Avatar asked Oct 21 '22 11:10

Hardik Joshi


1 Answers

You can use BitmapShader for achieve that..

Here is sample code.. Try this code, I hope it will work..

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);
like image 174
Niranj Patel Avatar answered Oct 31 '22 22:10

Niranj Patel