Skip to content Skip to sidebar Skip to footer

Background Image On The Recyclerview's Gridlayout Views Android

This is my first question with SO. I've just used RecyclerView with a GridManagerLayout of CardViews. Now it all works perfectly with the CustomAdapter and all, but I want to set a

Solution 1:

Found the answer. Was a silly mistake! Was doing everything right, but the image was a bit to big and didn't get created. So tested a smaller image to chance it and it worked.....should of tried another image before asking on SO. Was expecting the OutOfMemory exception if it was a big picture problem. Thanks though to david145 and hars.

Solution 2:

Wrapping all of it into a LinearLayout and setting it's background works great for me:

<LinearLayoutandroid:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/background_light"><FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"><android.support.v7.widget.RecyclerViewandroid:id="@+id/recycler_view"android:scrollbars="vertical"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingTop="4dp"android:paddingBottom="8dp"android:clipToPadding="false"/></FrameLayout></LinearLayout>

You can also use a FrameLayout instead of the LinearLayout.

Solution 3:

i know it should work the way you are doing but can you try a hack by adding a imageview inside your FrameLayout with a background

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/background"tools:context="fragments.SpaceFlightFragment"><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/background"
 /><android.support.v7.widget.RecyclerViewandroid:id="@+id/recyclerView"android:layout_width="match_parent"android:layout_height="match_parent"/></FrameLayout></LinearLayout>

Post a Comment for "Background Image On The Recyclerview's Gridlayout Views Android"