I'm looking to try and implement this widget design. The one thing I'm struggling with is creating that circular dropshadow around transparency. Any suggestions?
One solution for circles: Use a radial gradient with an array of colors and change points. You can set it so from the center to 90% out the radial gradient is transparent, then from 90% to 100% you fade from transparent to black. Something like [transparent, transparent, black, transparent] and [0, 0.9, 0.9, 1.0]
Related
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.
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 make GradientDrawable for background like the image below.
Linear Gradient with same color in the top and bottom.
I made gradient drawable with start, center and end colors but couldn't set the size of center color.
I also tried <Layer-list> with 2 gradient shape-s but one overlays over the other and either I have gradient on the top or on the bottom.
Can anyone help me ?
use "rect" type ShapeDrawable and ShapeDrawable.ShaderFactory
when implementing ShapeDrawable.ShaderFactory return the LinearGradient using colors array with 4 colors (f.ex: white, dark_blue, dark_blue, white) and positions array with 4 positions (f.ex: 0, 0.2, 0.8, 1)
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.
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.