An ellipse is easy to create. So is a rectangle with rounded corners. But how do I create a velodrome shape?
That is, half a circle to the left + rectangle in the middle + half circle to the right. Like a straight sausage, if you want.
I want this as an XML drawable to be used as background for a TextView.
What you're describing is a rectangle with rounded corners, just a specific class of one. Simply increase the radius of your corners to half the height of your rectangle.
Related
I have created the following progressbar style and set the corner radius to both shapes (background, and pogress). But how i make corner straight not rounded?
like this
This is a gradient rectangle with rounded corners. The corner radious is 5dp and gray turns to completely transparent within 20dp.
How would I make this bitmap programmatically?
( It's important to have the corners do the same gradient color transition circularly. So I cannot use one rectangle gradient overlapping with an oval gradient coz this would create a darker area where the two gradients would overlap )
I want to have 3 TextViews that are surrounded with circles as below:
The text views are centered in the circles.
I was planning on using TextView's with backgrounds set to a drawable containing a circle.
However, to position the circle properly I need the radius of each circle.
I tried to use Drawable.GetBounds() and then find the hypotenuse of the boundary rectangle, but this doesn't yield the values I want.
How do I find the radius. Or is there a better way to go about this in general?
Am I stuck just using a custom View and overriding onDraw?
This was a really dumb question. The radius is set to whatever the width or height of the View is.
I've got a shape drawable with a radial gradient inside it. The shape is a rectangle, and I'm trying to position the center of the radial gradient near the bottom right corner. I can get it in the general vicinity using the centerX and centerY attributes set to values like 0.98, but I'm dealing with rectangles of different heights (same width), so the taller the rectangle is, the higher the center position is, relative to the bottom right corner.
It seems I can only position the center as a percentage of the view width/height, contrary to the documentation. That is, even without the "%" in the value, it is treated as a percentage.
What I'd like to do is somehow say "put the center 5dp up and to the left of the bottom right corner". Any ideas on how to accomplish that?
You might try use a Layer-List, there you can specify margins of overlaying layer items, which can be drawables.
I have some text in a relative layout.I know that we can draw a border with curves using stroke and corner in a separate xml.
Is there a way to apply gradient effect for the border constructed with the stroke? or is there any other way to draw a gradient border?
Thanks in advance.
I don't know of a way to do that trivially, but it seems like you could define two shape drawables and combine with a layer drawable. The bottom one would be a rounded corner rectangle with a gradient, the top one would be a slightly smaller rounded corner rectangle of whatever you wanted the interior color to be. The effect should be something like a stroke gradient, although I haven't tried it.