yanzhenjie / SwipeRecyclerView

:melon: RecyclerView侧滑菜单,Item拖拽,滑动删除Item,自动加载更多,HeaderView,FooterView,Item分组黏贴。
https://github.com/yanzhenjie/SwipeRecyclerView
Apache License 2.0
5.64k stars 1.09k forks source link

emptyView的问题 #235

Open yjandroid opened 5 years ago

yjandroid commented 5 years ago

使用BaseRecyclerViewAdapterHelper加载emptyView不居中。

yjandroid commented 5 years ago

使用原生的RecyclerView,加BaseRecyclerViewAdapterHelper,就是这个https://github.com/CymChad/BaseRecyclerViewAdapterHelper, 加载image的时候空布局是原来的布局位置。 image

使用了你的re后再用那个adapter加载空布局,布局会变形,图片不居中了。 image

yanzhenjie commented 5 years ago

现在使用的SwipeRecyclerView的版本多少?

yjandroid commented 5 years ago

implementation 'com.yanzhenjie:recyclerview-swipe:1.2.2'

LIXIUCAI commented 5 years ago

严大,这个问题还没解决吗

Andy957 commented 5 years ago

还没解决吗

Xudanli2809 commented 5 years ago

我用最新的implementation 'com.yanzhenjie.recyclerview:x:1.3.2',也有这个问题

w1570187062 commented 5 years ago

把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;
    }`
2318423730 commented 1 year ago

这个问题该怎么解决?