I can not enlarge the width of a centeral color with a gradient.
The goal is:
Larger center with some color, and transparent on sides.
Usage:
I hope this is what you had in mind. I am using layer-list
. I have used "@color/colorAccent"
for either end. Change it to "#0FFF"
to get a transparent color, which was required in the question.
-
-
Play around with the android:centerX
attributes till you get what you want.
OUTPUT
This is what the drawable preview looks like with centerX at 10% and 80%
now with centerX at 60% and 40%
EDIT
To get the same effect in a layout that uses match_parent
as the layout_width
parameter, split the gradient into two drawables and set it as background for 2 different ImageViews
or FrameLayouts
left_gradient.xml
right_gradient.xml
In your Layout xml file
Like with the previous case, tweak around with the values in android:centerX
of both the gradient files to get the desired result