<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#000"
android:centerColor="#00000000"
android:endColor="#000"
android:angle="270"
android:dither="true"
/>
</shape>
This is the code I tried but it ends up as pure black.
To create a gradient color we need to create a . xml file in the drawable folder. So go to app -> res -> drawable and right-click on drawable -> New -> Drawable Resource File and create gradient_drawable.
TRANSPARENT (which represents the same thing as @android:color/transparent ) is equal to 0 . The hex representation of 0 is #00000000 , which means that Color. TRANSPARENT is essentially a completely transparent Color.
A GradientDrawable is drawable with a color gradient for buttons, backgrounds, etc.
What about this gradient? Full transparency at top to 50% transparent black at bottom
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#00000000"
android:endColor="#80000000"
android:angle="270"
android:dither="true"
/>
</shape>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With