RecyclerView的item寬度不能全屏顯示
阿新 • • 發佈:2019-02-17
錯誤寫法:
@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);
}
正確寫法:
@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的根佈局