2017-08-04 40 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); 
}