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.
Related
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.
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)
Does anyone know how i can draw programmatically in android something like this (without using opengl)?
Pic
You can use shape drawables (circles and lines) to define elements and then combine them in one drawable with Layer List. All this can be defined in XML.
hi,
I'm trying to implement something similar to the image attached. I have two textviews one on top of the other and i want their borders to look like the one in the image. I was able to draw rounded corners by setting the cornerradii of the GradientDrawable but i have no clue as in how to draw the slope on the right side of the first textview.
Any help on how to do this is much appreciated!!
thanks.
I would in this case do the graphics in a some graphics editing program (Photshop, GIMP or Inkscape for example). Two different drawings, one for the top part and one for the bottom. Then convert the drawings to NinePatchDrawable to be used as backgrounds for the text views. Since this type of drawable can be made larger or smaller depending on the length of the text in the TextViews.
You can use a transparent background image instead of drawing the background. Else you can use the canvas.
Edit : bad image example :-)