嵌套两层recycleView时,无法填充屏幕时
方法一、内层 LayoutInflater 设置 inflate(R.layout.item_layout, parent, false);
View view = LayoutInflater.from(mContext).inflate(R.layout.item_layout, parent, false);
外层 LayoutInflater 设置 inflate(R.layout.item_layout, parent, false);
View view = LayoutInflater.from(mContext).inflate(R.layout.item,parent,false);
方法二 、给每一层的 RecyclerView 设置 LayoutManager 时重写方法 generateDefaultLayoutParams
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext) {
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
};
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recycler.setLayoutManager(layoutManager);