oleg.svs
oleg.svs

Reputation: 183

Gradient Transparent Background

I want to get a transparent gradient over the image, why does transparency work:

    <android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.twick.screens.custom.SquaredImageView
        android:id="@+id/rv_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/office"/>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#80abcdef" > //TRANSPARENT WORK
    </FrameLayout>

</android.support.v7.widget.CardView>

and so there is no

android:background="@drawable/background_gradient_blue_indigo>//TRANSPARENT NOT WORK

background_gradient_blue_indigo :

<?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
<gradient
    android:angle="0"
    android:endColor="#800055FA" //80 transaprent
    android:startColor="#807942DF" //80 transparent/>
</shape>

Upvotes: 1

Views: 145

Answers (1)

Ishita Sinha
Ishita Sinha

Reputation: 2294

Add android:alpha=0.8 (or whatever float value you want) along with android:background="@drawable/background_gradient_blue_indigo" to the FrameLayout.

However, please note that this will make the whole view transparent, not the drawable in the background.

Upvotes: 1

Related Questions