0

I am working on a Android Studio project where i have to use a recyclerview that looks like the image below, is there anyway i could make this and ever there is can somebody link me to some kind of tutorial?

enter image description here

Unskilled
  • 29
  • 5

2 Answers2

2

You can check my answer in this link .Using Recyclerview and GridLayoutManager. Define 2 types in your RecyclerAdapter.

Community
  • 1
  • 1
RoShan Shan
  • 2,924
  • 1
  • 18
  • 38
0

Create 2 view holder's and return your ViewType like this

@Override
public int getItemViewType(int position) {
    if (isPositionHeader(position)) {
        return TYPE_HEADER;
    }
    return TYPE_ITEM;
}

and get that viewType in onCreateViewHolder and use it like this

 @Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == TYPE_HEADER) {
        View headerView = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_recycler_view_header, parent, false);
        return new ViewHolderHeader(headerView);
    } else if (viewType == TYPE_ITEM) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_recycler_view_item, parent, false);
        ViewHolderItem viewHolder = new ViewHolderItem(itemView);
        return viewHolder;
    }
    throw new RuntimeException("there is no type that matches the type " + viewType + " + make sure your using types correctly");
}