安卓(Android)关于 RecyclerView 不能填充满宽度


RecyclerView 不能填充满屏幕宽度

RecyclerView 的 Adapter 在使用是,一定要

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(MyApp.mContext)
.inflate(R.layout.your_layout, parent, false);
return new YourViewHolder(view);
}

像上面这样,使用

LayoutInflater.from(mContext).inflate(R.layout.your_layout, parent, false);

 

这样的方式填充布局。

如果使用:

View.inflate(mContext, R.layout.your_layout,parent)

会出现布局宽度填充不满的情况。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM