Android渐变背景,逐渐变为透明。

8

我正在尝试让一个条形图淡入到我的RelativeLayout的背景中。基本上从后面开始,然后渐变为透明。你懂的。

这是我现在拥有的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" />
问题: 视图底部有一个尖锐的边缘。我很困惑,因为渐变是透明结束的。但是我仍然在视图的底部得到了一个尖锐的边缘。如何调整才能获得淡出的边缘?
1个回答

9

你的颜色都不是透明的。

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

你可以使用@android:color/transparent代替。


啊,我真傻!您先生真是眼力好!谢谢。我会在3分钟内接受的。 - Jay

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接