Open yjandroid opened 5 years ago
使用原生的RecyclerView,加BaseRecyclerViewAdapterHelper,就是这个https://github.com/CymChad/BaseRecyclerViewAdapterHelper, 加载的时候空布局是原来的布局位置。
使用了你的re后再用那个adapter加载空布局,布局会变形,图片不居中了。
现在使用的SwipeRecyclerView的版本多少?
implementation 'com.yanzhenjie:recyclerview-swipe:1.2.2'
严大,这个问题还没解决吗
还没解决吗
我用最新的implementation 'com.yanzhenjie.recyclerview:x:1.3.2',也有这个问题
把OnCreateViewHolder改一下就好了,如下: ` View contentView = mHeaderViews.get(viewType); if (contentView != null) { return new ViewHolder(contentView); }
contentView = mFootViews.get(viewType);
if (contentView != null) {
return new ViewHolder(contentView);
}
final RecyclerView.ViewHolder viewHolder = mAdapter.onCreateViewHolder(parent, viewType);
if (mOnItemClickListener != null) {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnItemClickListener.onItemClick(v, viewHolder.getAdapterPosition());
}
});
}
if (mOnItemLongClickListener != null) {
viewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
mOnItemLongClickListener.onItemLongClick(v, viewHolder.getAdapterPosition());
return true;
}
});
}
if (mSwipeMenuCreator == null)
return viewHolder;
if (getItemCount() > 1) {
contentView = mInflater.inflate(R.layout.x_recycler_view_item, parent, false);
ViewGroup viewGroup = contentView.findViewById(R.id.swipe_content);
viewGroup.addView(viewHolder.itemView);
try {
Field itemView = getSupperClass(viewHolder.getClass()).getDeclaredField("itemView");
if (!itemView.isAccessible())
itemView.setAccessible(true);
itemView.set(viewHolder, contentView);
} catch (Exception ignored) {
}
return viewHolder;
} else {
return viewHolder;
}`
这个问题该怎么解决?
使用BaseRecyclerViewAdapterHelper加载emptyView不居中。