I'm tring to make some like RecyclerView list item image grid. It's has one main big image and some with other sizes. I've idea to use some like other holders for each image count, and choose it in adapter onCreateViewHolder method. But, I think, isn't good idea. Maybe you know some libraries or know some good practice examples?
Asked
Active
Viewed 711 times
2
-
Use a Image Library like Picasso or something similiar. – Murat Karagöz Aug 31 '16 at 12:31
-
picasso it's for image load. But I need layout with dinamic change of images views – Александр Шевчук Aug 31 '16 at 12:34
-
No need to use a library simply use glide or picasso for image caching. And create ViewHolder for each type of item. and change itemType on basis of your layout. and you are good to go. – Zar E Ahmer Aug 31 '16 at 12:34
-
https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView and http://stackoverflow.com/questions/25914003/recyclerview-and-handling-different-type-of-row-inflation may help – Zar E Ahmer Aug 31 '16 at 12:36
-
follow this link https://github.com/yuvaraj119/Picasso-RecyclerView-StaggeredGridLayoutManager – karthickraja Aug 31 '16 at 12:43
-
Also this one would work for you http://android-er.blogspot.com.tr/2015/11/gallery-like-recyclerview-cardview.html – Burak Cakir Aug 31 '16 at 12:45
1 Answers
0
You can do this with GridLayoutManager
and a custom SpanSizeLookup
.
GridLayoutManager
gives you the capability of saying how many columns (rows) you want a certain item to span by creating a SpanSizeLookup
. The code looks like this:
// Create a grid layout with four columns
GridLayoutManager layoutManager = new GridLayoutManager(this, 4);
// Create a custom SpanSizeLookup where the first item spans all four columns
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return position == 0 ? 4 : 1;
}
});

kris larson
- 30,387
- 5
- 62
- 74