In your adapter where you are inflating the item in onCreateViewHolder
, is the second parameter of the inflate
call null
?.
If so change it to parent
which is the first parameter in the onCreateViewHolder
function signature.
View rootView = LayoutInflater.from(context).inflate(R.layout.itemLayout, parent, false);
If you need the second parameter to be null
then when you get the view reference on inflating, do the following
View rootView = LayoutInflater.from(context).inflate(R.layout.itemLayout, null, false);
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rootView.setLayoutParams(lp);
return new RecyclerViewHolder(rootView);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…