2016-01-20 270 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