【问题标题】:Recycler View - Overlap items from right cuts the last one回收站视图 - 从右侧重叠项目切最后一个
【发布时间】:2017-07-18 00:00:31
【问题描述】:

我想将 recycler 中的每个元素重叠到右侧,因为我正在实现 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));

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

【问题讨论】:

    标签: java android android-recyclerview


    【解决方案1】:

    我终于找到了解决问题的方法,它是 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"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      • 1970-01-01
      相关资源
      最近更新 更多