How to make shape like on image?
Bottom left and right corners is simple. But top left and right corners...
radius="-10dp" won't work
For more complex shapes such as the one you are looking for you are better off using either vector or PNG resources than shape drawables.
Shape drawables are great for very simple shapes, but don't support a full suite of drawing options.
Related
How would I go about drawing a shape like this? I can't just use a half circle, because I want the edges to have a nice concave feel as they even out to flat. After that I'm looking to add a border to just the top part. How could this be done in xml?
You wouldn't use xml for this. Use an image, possibly a vector drawable.
Like the image on the right,
I want to treat multiple separated shapes as 1 shape in the color gradient behavior!
Any Ideas?!
That is like four separate squares, so no compound shapes? In any case ShapeDrawable, those SVG-like XML vector drawing tools, with clips at the end.
How would I replicate this in Android, my general instinct would be to create a regular layout w/ a border, then have 2 layouts that contain a triangle (one the same color as the border + one that's slightly smaller but white and overlap the two), idk if there's an easier way to do that:
You can use 9patch to achieve something like you wanted.
The Draw 9-patch tool is a WYSIWYG editor that allows you to create
bitmap images that automatically resize to accommodate the contents of
the view and the size of the screen. Selected parts of the image are
scaled horizontally or vertically based indicators drawn within the
image.
A complete guideline can be found here : http://developer.android.com/tools/help/draw9patch.html
The easiest way to reach this, is to set the layout background to that image.
background="#drawable/template"
Probably you want to have the area out of the "bubble" transparent, so you will need to save it as PNG.
I would like to include a bottom right triangle on the background of each item in a listview.
I can achieve this using nine-patch images:
But, there can be different possible colors, so I would like to do this with XML drawables, so that I can easily add more colors.
My questions are 2:
1) How I can draw triangles as XML drawables? (I have realized that the triangle is not one of the possible drawing shapes in Android)
2) In case I manage to achieve a triangle drawable, how can I force that drawable to say at the bottom right background? (with nine-patch images is pretty easy, but I don't know how to do the same with drawables)
1) If there is no need for scaling then you could simply take your ninepatch drawable and recolor it. For example if your base triangle had transparent background and the triangle was white you could do something like this to color it into red:
NinePatch ninePatch;
NinePatchDrawable drawable = new NinePatchDrawable(ninePatch);
drawable.setColorFilter(Color.RED, Mode.MULTIPLY);
2) Solved since you know how to do it with ninepatches
Hello fellow Android designers,
I am struggling right now to create xml tooltip that would look like the one on this picture:
Unfortunately it seems like a hell of a work. Till now I was only able to create a simple rounded rectangle like that:
Is it actually possible to create such a shape I have presented on the first photo using xml styling or should I try to create it programatically (which will probably take huge amount of time and creating border would be really hard)? Or maybe the simplest solution is the best and I should use partially transparent png image with the shape of my choosing?
Any advice would be much appreciated.
You can draw it using stretchable 9-patch drawable.
You can specify there which parts are fixed (the little knob on the left and corners) and which are stretchable (all other parts)