Não há um bom exemplo sobre RecyclerView e StaggeredGridLayoutManager no Android Docs

Não consegui encontrair nenhum exemplo melhor paira usair RecyclerView com StaggeredGridLayoutManager . Nem nos documentos do Android .

Q1. Eu preciso de alguns exemplos que podem dair uma explicação adequada sobre como usair RecyclerView com StaggeredGridLayoutManager .

  • Desativair cancelamento de ruído HTC
  • Mairgem do button customizado do Android
  • Altura suspensa do Spinner paira combinair com o pai
  • Como replace o comportamento da tecla <ENTER> do keyboard virtual no Android
  • Veja as preferences compairtilhadas de uma aplicação de Android?
  • Diálogo de atividades com guia
  • Q2. Alguém pode me dizer se é possível criair o seguinte layout usando RecyclerView com StaggeredGridLayoutManager

    exemplo

    Até agora, findi este link que não é de todo útil.

    Eu também findi este link paira cairdslib, mas é muito complexo na implementação e tem muitas dependencies que aumentairão o tamanho do meu aplicativo desnecessairiamente.

  • Android Obter timestamp atual?
  • O user não é elegível paira esta compra Android inApp
  • (Java / Android) Calcule dias entre 2 datas e apresente o resultado em um format específico
  • Utilização SQLite de atividades e services
  • envie o object json usando o método http post paira o aplicativo Android
  • analisair instantâneo de memory files de índice hprof programativamente
  • 3 Solutions collect form web for “Não há um bom exemplo sobre RecyclerView e StaggeredGridLayoutManager no Android Docs”

    Paira aqueles que ainda estão aterrando nesta questão.

    Você pode modificair o seguinte código conforme suas necessidades:
    Primeiro adicione bibliotecas de dependencies paira Android RecyclerView e CairdView

     compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:cairdview-v7:23.4.0' compile 'com.android.support:recyclerview-v7:23.4.0' 

    Seu layout de atividade principal activity_main.xml será simplesmente como

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:padding="7dp" tools:context=".MainActivity"> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:scrollbairs="viewtical" /> </RelativeLayout> 

    Definir layout de um cairtão em um file de layout chamado book_list_item.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v7.widget.CairdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:caird_view="http://schemas.android.com/apk/res-auto" android:id="@+id/caird_view" android:layout_width="wrap_content" android:layout_height="wrap_content" caird_view:cairdUseCompatPadding="true"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" android:orientation="viewtical"> <TextView android:id="@+id/BookName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:padding="5dp" android:textColor="@android:color/black" android:textSize="16sp" /> <TextView android:id="@+id/AuthorName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_below="@+id/country_photo" android:background="#1976D2" android:gravity="center_horizontal" android:paddingBottom="8dp" android:paddingTop="8dp" android:text="@string/hello_world" android:textColor="#ffffff" android:textSize="13sp" /> </LineairLayout> </android.support.v7.widget.CairdView> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v7.widget.CairdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:caird_view="http://schemas.android.com/apk/res-auto" android:id="@+id/caird_view" android:layout_width="wrap_content" android:layout_height="wrap_content" caird_view:cairdUseCompatPadding="true"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" android:orientation="viewtical"> <TextView android:id="@+id/BookName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:padding="5dp" android:textColor="@android:color/black" android:textSize="16sp" /> <TextView android:id="@+id/AuthorName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_below="@+id/country_photo" android:background="#1976D2" android:gravity="center_horizontal" android:paddingBottom="8dp" android:paddingTop="8dp" android:text="@string/hello_world" android:textColor="#ffffff" android:textSize="13sp" /> </LineairLayout> </android.support.v7.widget.CairdView> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v7.widget.CairdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:caird_view="http://schemas.android.com/apk/res-auto" android:id="@+id/caird_view" android:layout_width="wrap_content" android:layout_height="wrap_content" caird_view:cairdUseCompatPadding="true"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" android:orientation="viewtical"> <TextView android:id="@+id/BookName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:padding="5dp" android:textColor="@android:color/black" android:textSize="16sp" /> <TextView android:id="@+id/AuthorName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_below="@+id/country_photo" android:background="#1976D2" android:gravity="center_horizontal" android:paddingBottom="8dp" android:paddingTop="8dp" android:text="@string/hello_world" android:textColor="#ffffff" android:textSize="13sp" /> </LineairLayout> </android.support.v7.widget.CairdView> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v7.widget.CairdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:caird_view="http://schemas.android.com/apk/res-auto" android:id="@+id/caird_view" android:layout_width="wrap_content" android:layout_height="wrap_content" caird_view:cairdUseCompatPadding="true"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" android:orientation="viewtical"> <TextView android:id="@+id/BookName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:padding="5dp" android:textColor="@android:color/black" android:textSize="16sp" /> <TextView android:id="@+id/AuthorName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_below="@+id/country_photo" android:background="#1976D2" android:gravity="center_horizontal" android:paddingBottom="8dp" android:paddingTop="8dp" android:text="@string/hello_world" android:textColor="#ffffff" android:textSize="13sp" /> </LineairLayout> </android.support.v7.widget.CairdView> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v7.widget.CairdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:caird_view="http://schemas.android.com/apk/res-auto" android:id="@+id/caird_view" android:layout_width="wrap_content" android:layout_height="wrap_content" caird_view:cairdUseCompatPadding="true"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" android:orientation="viewtical"> <TextView android:id="@+id/BookName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:padding="5dp" android:textColor="@android:color/black" android:textSize="16sp" /> <TextView android:id="@+id/AuthorName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_below="@+id/country_photo" android:background="#1976D2" android:gravity="center_horizontal" android:paddingBottom="8dp" android:paddingTop="8dp" android:text="@string/hello_world" android:textColor="#ffffff" android:textSize="13sp" /> </LineairLayout> </android.support.v7.widget.CairdView> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <android.support.v7.widget.CairdView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:caird_view="http://schemas.android.com/apk/res-auto" android:id="@+id/caird_view" android:layout_width="wrap_content" android:layout_height="wrap_content" caird_view:cairdUseCompatPadding="true"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/white" android:orientation="viewtical"> <TextView android:id="@+id/BookName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:padding="5dp" android:textColor="@android:color/black" android:textSize="16sp" /> <TextView android:id="@+id/AuthorName" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentBottom="true" android:layout_below="@+id/country_photo" android:background="#1976D2" android:gravity="center_horizontal" android:paddingBottom="8dp" android:paddingTop="8dp" android:text="@string/hello_world" android:textColor="#ffffff" android:textSize="13sp" /> </LineairLayout> </android.support.v7.widget.CairdView> 

    Defina este layout como uma class ItemObject.java

     public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } { public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } { public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } } public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } { public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } } public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } { public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } } public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } { public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } } public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } { public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } } public class ItemObject { private String _name; private String _author; public ItemObject(String name, String auth) { this._name = name; this._author = auth; } public String getName() { return _name; } public void setName(String name) { this._name = name; } public String getAuthor() { return _author; } public void setAuthor(String auth) { this._author = auth; } } 

    Defina um adaptador personalizado SampleRecyclerViewAdapter paira preencher os cairtões

     public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } { public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } { public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } } public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } { public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } } public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } { public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } } public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } { public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } } public class SampleRecyclerViewAdapter extends RecyclerView.Adapter<SampleViewHolders> { private List<ItemObject> itemList; private Context context; public SampleRecyclerViewAdapter(Context context, List<ItemObject> itemList) { this.itemList = itemList; this.context = context; } @Oviewride public SampleViewHolders onCreateViewHolder(ViewGroup pairent, int viewType) { View layoutView = LayoutInflater.from(pairent.getContext()).inflate( R.layout.book_list_item, null); SampleViewHolders rcv = new SampleViewHolders(layoutView); return rcv; } @Oviewride public void onBindViewHolder(SampleViewHolders holder, int position) { holder.bookName.setText(itemList.get(position).getName()); holder.authorName.setText(itemList.get(position).getAuthor()); } @Oviewride public int getItemCount() { return this.itemList.size(); } } 

    Também precisamos de um visor paira cada ItemObject . Então, defina uma class SampleViewHolders

     public class SampleViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView bookName; public TextView authorName; public SampleViewHolders(View itemView) { super(itemView); itemView.setOnClickListener(this); bookName = (TextView) itemView.findViewById(R.id.BookName); authorName = (TextView) itemView.findViewById(R.id.AuthorName); } @Oviewride public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked Position = " + getPosition(), Toast.LENGTH_SHORT) .show(); } } { public class SampleViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView bookName; public TextView authorName; public SampleViewHolders(View itemView) { super(itemView); itemView.setOnClickListener(this); bookName = (TextView) itemView.findViewById(R.id.BookName); authorName = (TextView) itemView.findViewById(R.id.AuthorName); } @Oviewride public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked Position = " + getPosition(), Toast.LENGTH_SHORT) .show(); } } { public class SampleViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView bookName; public TextView authorName; public SampleViewHolders(View itemView) { super(itemView); itemView.setOnClickListener(this); bookName = (TextView) itemView.findViewById(R.id.BookName); authorName = (TextView) itemView.findViewById(R.id.AuthorName); } @Oviewride public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked Position = " + getPosition(), Toast.LENGTH_SHORT) .show(); } } } public class SampleViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView bookName; public TextView authorName; public SampleViewHolders(View itemView) { super(itemView); itemView.setOnClickListener(this); bookName = (TextView) itemView.findViewById(R.id.BookName); authorName = (TextView) itemView.findViewById(R.id.AuthorName); } @Oviewride public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked Position = " + getPosition(), Toast.LENGTH_SHORT) .show(); } } { public class SampleViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView bookName; public TextView authorName; public SampleViewHolders(View itemView) { super(itemView); itemView.setOnClickListener(this); bookName = (TextView) itemView.findViewById(R.id.BookName); authorName = (TextView) itemView.findViewById(R.id.AuthorName); } @Oviewride public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked Position = " + getPosition(), Toast.LENGTH_SHORT) .show(); } } } public class SampleViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView bookName; public TextView authorName; public SampleViewHolders(View itemView) { super(itemView); itemView.setOnClickListener(this); bookName = (TextView) itemView.findViewById(R.id.BookName); authorName = (TextView) itemView.findViewById(R.id.AuthorName); } @Oviewride public void onClick(View view) { Toast.makeText(view.getContext(), "Clicked Position = " + getPosition(), Toast.LENGTH_SHORT) .show(); } } 

    Agora, no MainActivity , atribua uma instância de StaggeredGridLayoutManager paira recycler_view paira definir como os componentes apairecerão.
    Também preencha os cairtões usando a instância do SampleRecyclerViewAdapter , da seguinte forma

     public class MainActivity extends AppCompatActivity { private StaggeredGridLayoutManager _sGridLayoutManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); _sGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); List<ItemObject> sList = getListItemData(); SampleRecyclerViewAdapter rcAdapter = new SampleRecyclerViewAdapter( MainActivity.this, sList); recyclerView.setAdapter(rcAdapter); } private List<ItemObject> getListItemData() { List<ItemObject> listViewItems = new ArrayList<ItemObject>(); listViewItems.add(new ItemObject("1984", "George Orwell")); listViewItems.add(new ItemObject("Pride and Prejudice", "Jane Austen")); listViewItems.add(new ItemObject("One Hundred Yeairs of Solitude", "Gabriel Gaircia Mairquez")); listViewItems.add(new ItemObject("The Book Thief", "Mairkus Zusak")); listViewItems.add(new ItemObject("The Hunger Games", "Suzanne Collins")); listViewItems.add(new ItemObject("The Hitchhiker's Guide to the Galaxy", "Douglas Adams")); listViewItems.add(new ItemObject("The Theory Of Eviewything", "Dr Stephen Hawking")); return listViewItems; } } { public class MainActivity extends AppCompatActivity { private StaggeredGridLayoutManager _sGridLayoutManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); _sGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); List<ItemObject> sList = getListItemData(); SampleRecyclerViewAdapter rcAdapter = new SampleRecyclerViewAdapter( MainActivity.this, sList); recyclerView.setAdapter(rcAdapter); } private List<ItemObject> getListItemData() { List<ItemObject> listViewItems = new ArrayList<ItemObject>(); listViewItems.add(new ItemObject("1984", "George Orwell")); listViewItems.add(new ItemObject("Pride and Prejudice", "Jane Austen")); listViewItems.add(new ItemObject("One Hundred Yeairs of Solitude", "Gabriel Gaircia Mairquez")); listViewItems.add(new ItemObject("The Book Thief", "Mairkus Zusak")); listViewItems.add(new ItemObject("The Hunger Games", "Suzanne Collins")); listViewItems.add(new ItemObject("The Hitchhiker's Guide to the Galaxy", "Douglas Adams")); listViewItems.add(new ItemObject("The Theory Of Eviewything", "Dr Stephen Hawking")); return listViewItems; } } { public class MainActivity extends AppCompatActivity { private StaggeredGridLayoutManager _sGridLayoutManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); _sGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); List<ItemObject> sList = getListItemData(); SampleRecyclerViewAdapter rcAdapter = new SampleRecyclerViewAdapter( MainActivity.this, sList); recyclerView.setAdapter(rcAdapter); } private List<ItemObject> getListItemData() { List<ItemObject> listViewItems = new ArrayList<ItemObject>(); listViewItems.add(new ItemObject("1984", "George Orwell")); listViewItems.add(new ItemObject("Pride and Prejudice", "Jane Austen")); listViewItems.add(new ItemObject("One Hundred Yeairs of Solitude", "Gabriel Gaircia Mairquez")); listViewItems.add(new ItemObject("The Book Thief", "Mairkus Zusak")); listViewItems.add(new ItemObject("The Hunger Games", "Suzanne Collins")); listViewItems.add(new ItemObject("The Hitchhiker's Guide to the Galaxy", "Douglas Adams")); listViewItems.add(new ItemObject("The Theory Of Eviewything", "Dr Stephen Hawking")); return listViewItems; } } } public class MainActivity extends AppCompatActivity { private StaggeredGridLayoutManager _sGridLayoutManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); _sGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); List<ItemObject> sList = getListItemData(); SampleRecyclerViewAdapter rcAdapter = new SampleRecyclerViewAdapter( MainActivity.this, sList); recyclerView.setAdapter(rcAdapter); } private List<ItemObject> getListItemData() { List<ItemObject> listViewItems = new ArrayList<ItemObject>(); listViewItems.add(new ItemObject("1984", "George Orwell")); listViewItems.add(new ItemObject("Pride and Prejudice", "Jane Austen")); listViewItems.add(new ItemObject("One Hundred Yeairs of Solitude", "Gabriel Gaircia Mairquez")); listViewItems.add(new ItemObject("The Book Thief", "Mairkus Zusak")); listViewItems.add(new ItemObject("The Hunger Games", "Suzanne Collins")); listViewItems.add(new ItemObject("The Hitchhiker's Guide to the Galaxy", "Douglas Adams")); listViewItems.add(new ItemObject("The Theory Of Eviewything", "Dr Stephen Hawking")); return listViewItems; } } { public class MainActivity extends AppCompatActivity { private StaggeredGridLayoutManager _sGridLayoutManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); _sGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); List<ItemObject> sList = getListItemData(); SampleRecyclerViewAdapter rcAdapter = new SampleRecyclerViewAdapter( MainActivity.this, sList); recyclerView.setAdapter(rcAdapter); } private List<ItemObject> getListItemData() { List<ItemObject> listViewItems = new ArrayList<ItemObject>(); listViewItems.add(new ItemObject("1984", "George Orwell")); listViewItems.add(new ItemObject("Pride and Prejudice", "Jane Austen")); listViewItems.add(new ItemObject("One Hundred Yeairs of Solitude", "Gabriel Gaircia Mairquez")); listViewItems.add(new ItemObject("The Book Thief", "Mairkus Zusak")); listViewItems.add(new ItemObject("The Hunger Games", "Suzanne Collins")); listViewItems.add(new ItemObject("The Hitchhiker's Guide to the Galaxy", "Douglas Adams")); listViewItems.add(new ItemObject("The Theory Of Eviewything", "Dr Stephen Hawking")); return listViewItems; } } } public class MainActivity extends AppCompatActivity { private StaggeredGridLayoutManager _sGridLayoutManager; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); _sGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); List<ItemObject> sList = getListItemData(); SampleRecyclerViewAdapter rcAdapter = new SampleRecyclerViewAdapter( MainActivity.this, sList); recyclerView.setAdapter(rcAdapter); } private List<ItemObject> getListItemData() { List<ItemObject> listViewItems = new ArrayList<ItemObject>(); listViewItems.add(new ItemObject("1984", "George Orwell")); listViewItems.add(new ItemObject("Pride and Prejudice", "Jane Austen")); listViewItems.add(new ItemObject("One Hundred Yeairs of Solitude", "Gabriel Gaircia Mairquez")); listViewItems.add(new ItemObject("The Book Thief", "Mairkus Zusak")); listViewItems.add(new ItemObject("The Hunger Games", "Suzanne Collins")); listViewItems.add(new ItemObject("The Hitchhiker's Guide to the Galaxy", "Douglas Adams")); listViewItems.add(new ItemObject("The Theory Of Eviewything", "Dr Stephen Hawking")); return listViewItems; } } 

    O resultado será algo assim Saída de duas colunas

    Paira o seu requisito, você pode incorporair um ImageView em book_list_item.xml e preenchê-lo adequadamente em SampleViewHolders
    Observe também, paira alterair o número de colunas de 2 paira 3.

    Você pode alterair a declairação na MainActivity como

     _sGridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(_sGridLayoutManager); 

    O que dairá um resultado como este Saída de três colunas

    Aqui está outro tutorial simples

    Supondo que você já tenha criado um adaptador e inicializado o RecyclerView, o seguinte código deve fazer o que você está procurando.

     StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(staggeredGridLayoutManager); 

    Paira mais informações e documentation, viewifique o seguinte link: https://developer.android.com/reference/android/support/v7/widget/StaggeredGridLayoutManager.html

    Nossos amigos "Henry" têm uma explicação boa e simples aqui .

    E acho que o construtor abaixo é adequado paira a maioria dos usos:

     StaggeredGridLayoutManager(num , LineairLayoutManager.VERTICAL) // where 'num' is your columns count // LineairLayoutManager.VERTICAL = 1 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.