Android Gradient Background that fades to be transparent

I am trying to make a panel fade in the background of my RelativeLayout. Basically, start from the back and then fade to be transparent. You get the idea.

Here xml I have:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="@color/black_translucent"
        android:endColor="#323232"
        android:angle="90"
        android:type="linear"
        android:useLevel="true"
        />
</shape>

And View I applied this to:

 <View
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:background="@drawable/gradient_top" />

Problem : The view has a sharp end edge at the bottom. I am confused as the gradient ends with transparent. However, I still get a shark rib at the bottom of the view. How can I tune this to get a fading edge?

+4
source share
1 answer

None of your colors are transparent.

@color/black_translucent suggests that it is transparent, opaque.

@android:color/transparent.

+5

Source: https://habr.com/ru/post/1625066/


All Articles