Jay
Jay

Reputation: 5084

Android Gradient Background that fades in to being Transparent

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

Here's the xml I have now:

<?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 the View I applied this to:

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

The problem: the View has a sharp ending edge at the bottom. I am confused since the gradient ends in transparent. However I still get a shark edge at the bottom of the View. How can I tweak this to get a fading edge?

Upvotes: 8

Views: 8292

Answers (1)

alex
alex

Reputation: 6409

Neither of your colours are transparent.

@color/black_translucent suggests that it's translucent, not transparent.

You could use @android:color/transparent instead.

Upvotes: 9

Related Questions