Android-Bug:RecyclerView的item不能橫向充滿的問題


在使用 RecyclerView 的時候,出現了 item 不能橫向充滿屏幕的問題,

如下圖所示:

 

解決辦法:發現是在使用 Adapter 的時候,在 onCreateViewHolder() 方法的時候,返回的 holder 的問題,

錯誤代碼:

return new CreateTODOViewHolder(
                    LayoutInflater.from(context).inflate(R.layout.item_date,null,false));

正確代碼:

return new CreateTODOViewHolder(
                    LayoutInflater.from(context).inflate(R.layout.item_date,parent,false));

 

結果如下圖所示:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM