安卓(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