在android 的开发过程中经常会使用的RecyclerView 相互嵌套,嵌套时会出子view显示不全的问题和子RecyclerView的宽度不能铺满屏幕;
解决方法如下:
1. 外层的RecyclerView Adapter设置
Override
public MyViewHonder onCreateViewHolder(ViewGroup parent,int viewType) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.pop_recyeler_outer_item, parent,false);
return new MyViewHonder(view);
}
2.内层的RecyclerView Adapter
@Override
public MyViewHonder onCreateViewHolder(ViewGroup parent,int viewType) {
LayoutInflater inflater = LayoutInflater.from(context);
View itemView = inflater.inflate(R.layout.pop_recyeler_inner_item,null);
return new MyViewHonder(itemView);
}
网友评论