如何制作透明渐变?


76

我有以下渐变:

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <gradient 
            android:startColor="#ECECEC"
            android:centerColor="#F6F6F4"
            android:endColor="#F8F8F6"
            android:angle="90"
            android:dither="true"
         />
    </shape>

我希望它是透明的,因为在ListView中,我将其设置为ListSelector:

<ListView android:layout_width="fill_parent"
                android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/ARListView" 
                android:background="@drawable/transparent_background" 
                android:cacheColorHint="#00000000" android:drawSelectorOnTop="true" 
                android:listSelector="@drawable/stocks_selected_gradient">
</ListView>

Answers:


140

只需使用8位数字的颜色值,例如#FFF8F8F6,其中前两个字符为alpha值。FF是完全不透明的,00是完全透明的。


3
最好使用@android:color / transparent而不是#00xxxxxx
饥饿的Androider

4

android:background =“#00000000” android:cacheColorHint =“#00000000”

这将是透明的,但是,这是使其完全透明...


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.