Gradient for border in Android - android

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.

Related

Android How to create a Glowing Border or Four side shadow Rectangle Shape Background

I want to fill the background of multiple size (custom width or height) constraint layouts with this design:
Noticed that the outline border is glowing with fading gold color.
I have tried with the following:
Attempt (A) is using of ImageView tag, but not scalable to custom width and height.
Attempt (B) is xml created. But the border color is not fading, isn't the desired result.
Attempt (C) is using 9 patch file. The border radius and corner radius does not seems correct at all. (Would also like to know reason of this)
This is my 9patch file:
May I know if this is even possible to achieve?
Anyone please help.

Android - create shadow drawable programmatically

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 )

Draw line with faded ends

Is it possible in Android to programmatically draw a line using a path, such that the middle section is a solid color but both ends fade from that color to transparent? The path will be a series of calculated coordinates.
Yes, use a generic View widget with a drawable that contains a gradient as its background.
Make sure it extends to match_parent in the direction you want it to cut your layout and it's 1px tall or wide in the other dimension.
The gradient should be a simple linear gradient transparent to solid to transparent.
Here is a very nice tutorial.
Update:
The above link is dead, try this one instead.

XML shape as layout background

I'm wondering if that's possible to create an effect as shown at the picture below using only 1 Layout. The "Description" is a separate TextView and not related to the question. So basically I need a rect shape with:
Glowing border (stroke and shadow..?)
Middle rectangle with gradient
Outer rectangle
Any ideas if this could be achieved using only one Layout and XML shape as background?

How to create a velodrome shape?

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.

Categories

Resources