I was trying my hand with recyclerview and floating action button for an app. The problem I encountered is that the floating action button hinders with the buttons in recyclervi
I have created an utility method for that so you can add padding easily
public void addLastChildPadding(RecyclerView.ViewHolder holder,int padding,int recyclerListSize,int position){
if(recyclerListSize-1==position){
holder.itemView.setPadding(0,0,0,padding);
}
}
Try this at once
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:background="@drawable/button_primary_color_border"
android:text="70%"
android:textColor="@android:color/darker_gray"
android:textSize="20sp" />
<android.support.v7.widget.AppCompatButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:background="@drawable/button_primary_color_border"
android:text="60%"
android:textColor="@android:color/darker_gray"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Remove images and other string according to your uses.
Here's an example (in this case a listView, but could be anything) underneath a recycler view that takes up the rest of the parent's height. Note layout_alignParentBottom and layout_above attributes.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
**android:layout_alignParentBottom="true"**
/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_above="@+id/list_view"
/>
Add bottom padding to the RecyclerView.
Also, don't use android:layout_height="wrap_content"
unless you've overridden onMeasure
in the layout manager. Current layout managers do not yet support wrap content.
Add the attribute android:clipToPadding="false"
to achieve the goal.
As mentioned in comments.