我想将recycleler中的每个元素重叠到右侧,因为我正在实现itemdecorator类,但是它也会从右边切割最后一个视图,对此的任何帮助都将不胜感激。
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));
答案 0 :(得分:4)
我终于找到了我的问题的解决方案,它是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"/>