StaggeredGridLayoutManager

suggest change
  1. Create your RecyclerView in your layout xml file:
<android.support.v7.widget.RecyclerView
            android:id="@+id/recycleView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
  1. Create your Model class for holding your data:
public class PintrestItem {
        String url;
        public PintrestItem(String url,String name){
            this.url=url;
            this.name=name;
        }
        public String getUrl() {
            return url;
        }
    
       public String getName(){
           return name;
       }
        String name;
    }
  1. Create a layout file to hold RecyclerView items:
<ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:id="@+id/imageView"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/name"
            android:layout_gravity="center"
            android:textColor="@android:color/white"/>
  1. Create the adapter class for the RecyclerView:
public class PintrestAdapter extends  RecyclerView.Adapter<PintrestAdapter.PintrestViewHolder>{
   private ArrayList<PintrestItem>images;
   Picasso picasso;
   Context context;
   public PintrestAdapter(ArrayList<PintrestItem>images,Context context){
       this.images=images;
       picasso=Picasso.with(context);
       this.context=context;

   }

   @Override
   public PintrestViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
       View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.pintrest_layout_item,parent,false);
       return new PintrestViewHolder(view);
   }

   @Override
   public void onBindViewHolder(PintrestViewHolder holder, int position) {
         picasso.load(images.get(position).getUrl()).into(holder.imageView);
         holder.tv.setText(images.get(position).getName());
   }

   @Override
   public int getItemCount() {
       return images.size();
   }

   public class PintrestViewHolder extends RecyclerView.ViewHolder{
       ImageView imageView;
       TextView tv;
       public PintrestViewHolder(View itemView) {
           super(itemView);
           imageView=(ImageView)itemView.findViewById(R.id.imageView);
           tv=(TextView)itemView.findViewById(R.id.name);
           
       }
   }
}
  1. Instantiate the RecyclerView in your activity or fragment:
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recyclerView);
//Create the instance of StaggeredGridLayoutManager with 2 rows i.e the span count and provide the orientation
StaggeredGridLayoutManager layoutManager=new new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
// Create Dummy Data and Add to your List<PintrestItem>
List<PintrestItem>items=new ArrayList<PintrestItem>
items.add(new PintrestItem("url of image you want to show","imagename"));
items.add(new PintrestItem("url of image you want to show","imagename"));
items.add(new PintrestItem("url of image you want to show","imagename"));
recyclerView.setAdapter(new PintrestAdapter(items,getContext() );

Don’t forgot to add the Picasso dependency in your build.gradle file:

compile 'com.squareup.picasso:picasso:2.5.2'

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


RecyclerView:
* StaggeredGridLayoutManager

Table Of Contents
2 Gradle
5 Intent
17 Service
19 WebView
21 RecyclerView
31 SQLite
35 Glide
37 Dialog
38 ACRA
44 Handler
53 Toast
63 Menu
65 Picasso
70 Volley
71 Widgets
78 Realm
90 Spinner
95 OkHttp
108 TextView
109 ListView
111 Loader
118 Xposed
119 Security
121 ImageView
123 Doze Mode
130 Drawables
131 Colors
134 Fresco
139 AdMob
145 Keyboard
146 Button
150 EditText
155 Vk SDK
163 ExoPlayer
169 XMPP
175 OpenCV
177 Threads
184 ORMLite
186 TabLayout
190 LruCache
192 Zip files
194 Fastlane
199 FileIO
202 Moshi
210 VideoView
216 Paint
218 ProGuard
226 CleverTap
228 ADB shell
229 Ping ICMP
230 AIDL
234 Context
240 JCodec
242 Okio
249 FuseView
254 Looper
261 Fastjson
263 Jackson
267 Smartcard