2017-07-18 62 views
2

我想重疊每個元素在回收商的權利,因爲我正在實施itemdecorator類,它的確如此,但它也削減了右邊的最後一個視圖,任何幫助這將不勝感激謝謝。Recycler View - 從右邊的重疊項目削減最後一個

public class ItemDecorator extends RecyclerView.ItemDecoration { 
private final int mSpace; 

public ItemDecorator(int space) { 
    this.mSpace = space; 
} 

@Override 
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 
    //outRect.left = mSpace; 
    outRect.right = mSpace; 
    //outRect.bottom = mSpace; 
    //outRect.top = mSpace; 
} 
} 

eventDetailBinding.participantList.setHasFixedSize(true); 
       RecyclerView.LayoutManager layoutManagerForParticipants = 
         new LinearLayoutManager(EventDetailActivity.this, LinearLayoutManager.HORIZONTAL, false); 
       eventDetailBinding.participantList.setLayoutManager(layoutManagerForParticipants); 
       ItemDecorator itemDecorator = new ItemDecorator(-30); 
       eventDetailBinding.participantList.addItemDecoration(itemDecorator); 
       eventDetailBinding.participantList.setAdapter(new ParticipantViewAdapter(EventDetailActivity.this, imageList)); 

圖片= https://image.ibb.co/hivnLF/Untitled.png

回答

2

我終於找到了解決我的問題,這是對我的看法回收和clipToPadding="false"設置paddingRight="8dp"

<android.support.v7.widget.RecyclerView 
          android:id="@+id/participant_list" 
          android:paddingLeft="4dp" 
          android:paddingRight="8dp" 
          android:clipToPadding="false" 
          android:layout_width="wrap_content" 
          android:layout_height="match_parent"/>