Open z-chu opened 6 years ago
解决办法:加个判断state.getItemCount()>0,不然 recycler.getViewForPosition(0)就会报IndexOutOfBoundsException错误
...
@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
if (getItemCount() != 0 && mItemCount != 0&&state.getItemCount()>0) {
View view = recycler.getViewForPosition(0);
...
非常感谢!
rride public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) { if (getItemCount() != 0 && mItemCount != 0&&state.getIt
判断之后,你会发现,最底部的无法选中, 测量出了问题
@Override public boolean isAutoMeasureEnabled() { if (this.mItemCount != 0){ return false; } return super.isAutoMeasureEnabled(); }
在LayoutManager按上述代码样式重写即可解决