skip to Main Content

So currently I set up the background image of the app main activity page, but the recycleview item is blocking it, is there a way to display my recycleview item without blocking the background image? I have try to add android::background = /transparent before and it did not work

My recycleview item have the following xml layout file:

<?xml version="1.0" encoding="utf-8"?>
  <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
>

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:textAppearance="?attr/textAppearanceHeadline6" />


    <TextView
        android:id="@+id/dueDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:textAppearance="?attr/textAppearanceHeadline6" />

    <TextView
        android:id="@+id/completeDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:textAppearance="?attr/textAppearanceHeadline6" />

    <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Complete" />

</LinearLayout>
 </com.google.android.material.card.MaterialCardView>

And my main activity have the following layout

<?xml version="1.0" encoding="utf-8"?>
 <androidx.constraintlayout.widget.ConstraintLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="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:background="@drawable/background2"
tools:context=".MainActivity">

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recyclerview"
    android:layout_width="0dp"
    android:layout_height="0dp"
    tools:listitem="@layout/recyclerview_item"
    android:padding="@dimen/big_padding"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    android:src="@drawable/ic_baseline_add_24dp"/>

 </androidx.constraintlayout.widget.ConstraintLayout>

enter image description here

2

Answers


  1. try to use android:background="@null"

    Login or Signup to reply.
  2. android:background="@null"
    

    or

    android:background="@android:color/transparent"
    

    You probably have to set the transparent background to both RecyclerView and its item.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search