Reputation: 1347
I am trying to implement different grid layout structure but unfortunately not getting success. So please look on below screenshot and tell me is it possible to implement gridview or recyclerview like below screenshot. Thanks in advance :)
Upvotes: 1
Views: 1182
Reputation: 1295
Use GridLayoutManager
with spancount
3
Now set the custom top margin to your root layout for the second position.
Apply this logic to your RecyclerViewAdapter's onBindViewHolder
if (position % 3 == 1) {
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
relativeParams.setMargins(0, 50, 0, 0); // left, top, right, bottom
holder.rel_root.setLayoutParams(relativeParams);
}
not sure if it's correct way but works :)
Upvotes: 3