I am attempting to convert CSS radial-gradient to Android and have found that I have needed RadialGradient because the CSS has multiple colors and stops. An example of the CSS is below.
background-image: radial-gradient(circle at 24% 50%, #ffffff, #c0e3e0 20%, #a4c4d7 61%, #000000);
I tried to use
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:centerX="36%"
android:centerY="50%"
android:endColor="#000000"
android:gradientRadius="300"
android:startColor="#ffffff"
android:type="radial"
/>
</shape>
but you cannot include all of the colors and no stops.
I went for RadialGradient
RadialGradient radialGradient = new RadialGradient(0.25f, 0.45f, 140.f, new int[]{
ContextCompat.getColor(context, R.color.background_gradient_start_color),
ContextCompat.getColor(context, R.color.background_gradient_second_color),
ContextCompat.getColor(context, R.color.background_gradient_third_color),
ContextCompat.getColor(context, R.color.background_gradient_end_color)}, new float[]{1.0f, 0.2f, .61f, 1.0f},
Shader.TileMode.CLAMP);
but I cannot set the RadialGradient as the background of my RelativeLayout since it is not android.graphics.Drawable or don't know how. Can someone provide a solution?