I want to draw a custom shape like this-.
One option is to make each shape in photoshop individually and then use it in coding but I want to know that is it possible to draw this using xml?
How should I draw the shape like this? Don't expect complete code, just give me idea or point me in the right direction.
Try the following shape drawable xml:
That's how it looks like on a white background:
Here is more info on Shape Drawables.
EDIT:
The following is a small explanation of how it's done.
top, bottom, right and left
attributes of thesize
tag of shape means the distance from the shape's borders totop, bottom, right and left
edges of the container (yellow rectangle).For example, if we want to place a smaller rectangle inside of the yellow one with a
10dp
gap from each yellow rectangle's edge we'd set thetop, bottom, right and left
attributes equal to10dp
for the new (inner) rectangle.size
tag attribute's values can be negative which means that the corresponding edge of the shape appears outside of the container. In the previous example, if you set, say, theleft
attribute to 100 dp or higher, the inner rectangle won't show up, because it'll be behind the right boarder of the yellow one.Regarding rotation, it goes clockwise for positive values and counterclockwise otherwise.
Hopefully, this didn't confuse you.