2017-08-04 80 views
-2

我在一个活动中添加了recyclerview和浮动操作按钮,其中每个recyclerview项目都有一些UI元素。其项目UI的最后一个元素不能被访问,因为它正在被浮动按钮覆盖如何仅为最后一个项目,以便它不应该被浮动操作覆盖并有资格访问。在Recyclerview中添加空间

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.packtpub.ups.customer.Second" 
android:background="#DCDCDC"> 
<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
</android.support.v7.widget.RecyclerView> 
<android.support.design.widget.FloatingActionButton 
    android:id="@+id/nextToThird" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:backgroundTint="@color/colorgreen" 
    android:src="@drawable/right" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="20dp" /> 
</RelativeLayout> 

这里是我的物品容器。

<LinearLayout 
    android:layout_height="50dp" 
    android:layout_width="match_parent" 
    android:layout_marginTop="20dp" 
    android:layout_marginBottom="20dp" 
    android:id="@+id/buttons"> 

<Button android:layout_height="40dp" 
    android:layout_width="80dp" 
    android:id="@+id/accept" 
    android:layout_marginTop="7dp" 
    style="@style/Widget.AppCompat.Button" 
    android:background="@drawable/scan_button" 
    android:layout_marginStart="30dp" 
    android:layout_marginLeft="30dp" 
    android:text="@string/Accept"/> 

<Button android:layout_height="40dp" 
    android:layout_width="80dp" 
    android:id="@+id/decline" 
    style="@style/Widget.AppCompat.Button" 
    android:background="@drawable/scan_button" 
    android:layout_marginStart="30dp" 
    android:layout_marginLeft="30dp" 
    android:text="@string/Decline"/> 

    <Button android:layout_height="40dp" 
     android:layout_width="80dp" 
     android:id="@+id/viewmode" 
     android:layout_marginTop="7dp" 
     style="@style/Widget.AppCompat.Button" 
     android:background="@drawable/scan_button" 
     android:layout_marginStart="30dp" 
     android:layout_marginLeft="30dp" 
     android:text="@string/Viewmode"/> 
    </LinearLayout> 

回答

1

使用下在XML RecyclerView标记线,

android:paddingBottom="85dp" 
android:clipToPadding="false" 
0

变化适配器

if (position == list.size()-1) 
{ 
    viewHolder.setPadding(150,0,0,0); 
}