RecyclerView的item宽度不能全屏显示

2022-06-10 11:14:22 浏览数 (1)

错误写法:

代码语言:javascript复制
@Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_complain_list, null, false);
        view.setOnClickListener(this);
        return new ViewHolder(view);
    }

正确写法:

代码语言:javascript复制
@Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_complain_list, parent, false);
        view.setOnClickListener(this);
        return new ViewHolder(view);
    }

此处传入的parent即为item的根布局

0 人点赞