Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an empty space after last element in a RecyclerView?

I am using RecyclerView from support.v7 library to display items on shopping list.
When I'm scrolling to the end of my data, I can't see the price in the right side of the last item.
I want to add some space after scrolling to the last item, so that the button don't cover it.

Here is the image of the App with RecyclerView and FAB:

App with RecyclerView and FAB

I can simply add an empty object to the list for an Adapter, but in this case it will behave like the rest of rows (it will have checkbox, and price 00.00 on the right side).

Is there another way to do that?

like image 950
Karola Avatar asked Nov 25 '18 20:11

Karola


People also ask

How to add dividers and spaces between items in recyclerview?

How to add dividers and spaces between items in RecyclerView? This example demonstrate about How to add dividers and spaces between items in RecyclerView Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

How to add margins to recyclerview items using itemdecoration?

Add the ItemDecoration to the RecyclerView as above. This adds equal spacing to the RecyclerView items as shown in the figure below. Instead of adding all the margins using the ItemDecoration, we can add the left, top, right margins in the item layout file and add a bottom margin to the last item using the below ItemDecoration.

How to add an itemdecoration instance to recyclerview?

There are two methods you can use to add an ItemDecoration instance to RecyclerView: All added instances of RecyclerView.ItemDecoration are put in a single list and drawn simultaneously.

How to create a recyclerview in Android Studio?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken recycerview.


Video Answer


1 Answers

You can add bottomPadding and disable clipping, such as:

<RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    <!-- Bottom Padding, or space below last item -->
    android:paddingBottom="10dp"

    <!-- Clipping diabled -->
    android:clipToPadding="false" />
like image 140
iFanie Avatar answered Oct 20 '22 20:10

iFanie