gpt4 book ai didi

java - Recycler View - 从右侧重叠项目切割最后一个

转载 作者:搜寻专家 更新时间:2023-11-01 07:45:31 25 4
gpt4 key购买 nike

我想将回收器中的每个元素重叠到右边,因为我正在实现 itemdecorator 类,它确实这样做了,但它也从右边切掉了最后一个 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

最佳答案

我终于找到了我的问题的解决方案,它是 clipToPadding="false" 并在我的回收站 View 上设置 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"/>

关于java - Recycler View - 从右侧重叠项目切割最后一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45155376/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com