android - RecyclerView的item不能横向充满的问题

浏览:27日期:2022-11-24

问题描述

RecyclerView的item中一个LinearLayout中包裹了一个TextView,但是TextView在RecyclerView中显示的始终是Wrap_content,始终不能显示出match_parent的效果

问题解答

回答1:

如果布局文件没错的话,请检查在RecyclerView的Adapter中的onCreateViewHolder方法中是否正确加载布局文件例如:

View view = mLayoutInflater.inflate(R.layout.item, parent, false);回答2:

你inflate子view的时候,parent是不是传的null

回答3:

把你的xml代码贴出来看看

相关文章: