How to make transparent gradient?

AndroidListviewTransparencyGradient

Android Problem Overview


I have the following gradient:

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

I want this to be transparent because in my ListView I am setting this as my 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>

Android Solutions


Solution 1 - Android

Just use an 8-digit color value, e.g. #FFF8F8F6, where the first two characters are the alpha value. FF being fully opaque, and 00 being fully transparent.

Solution 2 - Android

android:background="#00000000" android:cacheColorHint="#00000000"

this will make is transparent however, this is to make it a full transparency...

Solution 3 - Android

You can try the following code :

<gradient android:startColor="#hex_of_any_color" android:endColor="#00000"/>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSheehan AlamView Question on Stackoverflow
Solution 1 - AndroidKevin CoppockView Answer on Stackoverflow
Solution 2 - AndroidCadTechView Answer on Stackoverflow
Solution 3 - AndroidPranav PrakasanView Answer on Stackoverflow