jeudi 23 juin 2016

How to Make GridLayout Background Transparent?

I am implementing GridLayout in a recycler view with Images loading from the drawable folder.

Image Link here

So as you can see , the background is white and I want to make it Transparent, My XML code for this layout is

<?xml version="1.0" encoding="utf-8"?>


<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000"
    android:id="@+id/card"
    card_view:cardCornerRadius="3dp"
    card_view:cardElevation="2dp"
    card_view:cardUseCompatPadding="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="4dp"
        android:scaleType="centerCrop" />
    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:text="Abcd"
        android:textSize="18dp"
        android:textStyle="bold"
        android:textAllCaps="true"
        android:textColor="#ffffff"
        android:layout_marginTop="140dp"/>
</RelativeLayout>


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

I have tried a lot of things that such as :-

  • Making Recycler View's alpha as 0
  • Card View's Alpha as 0
  • Setting Card Background Color to Transparent and setting Max Elevation to 0 so as to reduce the shadow

Still, I am not able to get the transparent Background. Can anyone suggest a new way?

Also , the Images used are Vector Images with transparent background.

Aucun commentaire:

Enregistrer un commentaire