RecyclerView 相互嵌套内层RecyclerView显

2018-02-08  本文已影响0人  黑白岩

在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);

}

上一篇下一篇

猜你喜欢

热点阅读