2016-01-20 266 views
4

我想讓一個酒吧淡入到我的RelativeLayout背景。基本上從後面開始,然後淡入透明。你明白了。Android漸變背景漸變爲透明

這裏的XML我現在有:

<?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> 

和視圖我申請這:

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

問題:查看在底部尖銳的結局邊緣。我很困惑,因爲漸變以透明結束。不過,我仍然在視圖的底部看到鯊魚的邊緣。我怎樣才能調整這個來獲得衰落的邊緣?

回答

5

你的顏色都不是透明的。

@color/black_translucent表明它是半透明的,不透明。

您可以改爲使用@android:color/transparent

+0

啊啊傻我!你先生,有一顆好眼睛!謝謝。我會在3分鐘內接受 – Dinuka