如下图,item宽度设置的match_parent,却还是没能铺满父布局。
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == TITLE){
return new TitleViewHolder(mLayoutInflater.inflate(R.layout.wait_item_title,null));
}else if (viewType == ADDRESS){
return new AddressViewHolder(mLayoutInflater.inflate(R.layout.order_address, null));
}else if (viewType == GOODS){
}
return null;
}
改为:
return new TitleViewHolder(mLayoutInflater.inflate(R.layout.wait_item_title,parent,false));
问题就解决了。