Android , Java , drawing specific shape like arc - android

I want to create a customview which will draw a specific shape .
So I try to override the onDraw function of View class and draw a shape by canvas class . But I couldnt found the solution to draw what I want .
Here is the shape that I want to draw (the color part and the rest is transparent not white)
Target shape
Please help me !! Thanks all in advance

You can create a white rounded corner in a layout which background is red (example code here : http://androidcookbook.com/Recipe.seam?recipeId=2318)

Related

Set Background Image for a Shape drawn by Canvas

The goal is to draw some hexagons on the screen and set different background images for those hexagons (I'm making a broad game). I have read about the Shape in XML file, but i want to draw it programmatically. I have drawn a shape with the help of canvas like this:
Path hexPath = hex.getPath();
canvas.clipPath(hexPath);
canvas.drawColor(Color.RED);
how can i set up the background image for this shape ?
I also have read about cropping a Bitmap, but is not practical for me.
Thanks.

how create circle drawables like below

I would like to create drawables like the following so that I can adjust the colour at run time.
I can easily create the drawable with a stroke around a colour but all it does is create the line on the edge of the circle, but I need to have the white line on the inside with the same colour as the center on the outside?
Anyone have any ideas?
Thanks
I think this is what you are looking for.
You basically override the onDraw method of your view and call drawCircle(x, y, radius, paint) with the parameters on the link.

Draw Custom Shape

How I can draw this type of shape and change color in runtime
I am referring this Making a triangle shape using xml definitions? but its not giving as expecting result
Use 9 patch image For that.
9 patch image
Or Here you can make that shape Direct,
Draw trapezoid shape

how to draw custom custom circle inside rectangle shape using custom view in android

how to draw custom custom circle inside rectangle shape using custom view.after drawing it should be expand the rectangle shape when ever you drag the edges of that rectangle.how to draw custom custom circle inside rectangle shape using custom view.after drawing it should be expand the rectangle shape when ever you drag the edges of that rectangle
You need to use drawRect, drawOval/drawArc for this. Read more from here:
http://developer.android.com/reference/android/graphics/Canvas.html

Transparecy in canvas android

I want to add canvas (somewhat transparent in color) on background which has some image on its Ontouch event. I want to remove that transparent color of canvas which makes my background image clear.
I'm using:
paint.setColor(Color.TRANSPARENT);
but nothing is happening on canvas. Any help would be greatly appreciated.
i have added transparent canvas on background...which makes my image above:
and ontouch resultant should be like this:

Categories

Resources