I have a nested list like A{a1, a2, a3...aN}, B{B1, BM}, .... O{O1, o2, ... OP} this. The list has a random number of members. Each member is also list with random of members. This will be shown like below image. As you see, outer cell's width and height is not fixed. I guess maybe it can be possible if I use nested recyclerview. It is little bit like StaggeredGridLayoutManager. But as I understood, StaggeredGridLayoutManager should have one of width or height should be fixed. Any suggestion how to implement this kind of UI design? This is what I want to display
This is what displayes when I use StaggeredGridLayoutManager
This is outer List Adapter /********** class GroupAdapter extends RecyclerView.Adapter{
@Override
public GroupHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_group, null);
GroupHolder ih = new GroupHolder(v);
return ih;
}
@Override
public void onBindViewHolder(GroupHolder holder, int position) {
if(mGroups!=null && mGroups.size()>position) {
GroupObject group = mGroups.get(position);
ArrayList<CandidateObject> cans = group.getCandidates();
CandidateAdapter adapter = new CandidateAdapter(cans);
CustomLinearLayoutManager mLinearManager = new CustomLinearLayoutManager(MainActivity.this);
mLinearManager.setAutoMeasureEnabled(true);
holder.rvCandis.setLayoutManager(mLinearManager);
holder.tvTitle.setText(group.getName());
holder.rvCandis.setAdapter(adapter);
}
}
@Override
public int getItemCount() {
return mGroups.size();
}
}
private static class GroupHolder extends RecyclerView.ViewHolder {
private TextView tvTitle;
private RecyclerView rvCandis;
public int index;
private GroupHolder(View v) {
super(v);
this.tvTitle = (TextView) v.findViewById(R.id.tv_partyname);
this.rvCandis = (RecyclerView) v.findViewById(R.id.rvCandi);
}
}
And this is Inner list adapter class CandidateAdapter extends RecyclerView.Adapter{ ArrayList candis;
CandidateAdapter(ArrayList<CandidateObject> candis){
this.candis = candis;
}
@Override
public CandidateHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_candidate, null);
CandidateHolder ih = new CandidateHolder(v);
return ih;
}
@Override
public void onBindViewHolder(CandidateHolder holder, int position) {
if(candis!=null && candis.size()>position) {
CandidateObject c = candis.get(position);
holder.tvName.setText(c.getName());
}
}
@Override
public int getItemCount() {
return candis.size();
}
}
private static class CandidateHolder extends RecyclerView.ViewHolder {
private ImageView ivThumb;
private TextView tvName;
public int index;
private CandidateHolder(View v) {
super(v);
this.tvName = (TextView) v.findViewById(R.id.tv_name);
this.ivThumb = (ImageView) v.findViewById(R.id.ivNaver);
}
}
StaggeredGridLayoutManager is made like this.
setContentView(R.layout.activity_main);
StaggeredGridLayoutManager mLayManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
mRvVote = (RecyclerView) findViewById(R.id.rvVote);
mRvVote.setLayoutManager(mLayManager);