Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView with GridLayoutManager [duplicate]

What's the best and easiest way to decorate RecyclerView to have such look & feel? i am developing an travels seat booking application... i know i can do it with recyclerview with gridlayout manager..but what should be the steps i dont know one thing to be note each bus have different seating arrangemen

enter image description here

enter image description here

enter image description here

like image 228
Tufan Avatar asked Jul 28 '15 05:07

Tufan


People also ask

How to implement recycleview with gridlayoutmanager in Android?

Let’s us now start implementing our android application with RecycleView with GridLayoutManager with example. Step 1: Create a New Project And Name It RecyclerViewExample. OfCouse, your need to create a new android project using android-studio, or else you can make use of your existing android project.

How to set grid layout in recyclerview?

if you want to set grid layout in reyclerview in xml file then you can put these two in in recyclerview xml. if you want to set grid layout from java code you can write this. in your MainActivity, where u assigned your recycler view, just use this code.

How to create a recyclerview in Android Studio?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken recycerview. Step 3 − Add the following code to src/MainActivity.java

What are the different types of layout managers for recycler view?

There are two types of layout managers for Recycler View to implement. In linear layout manager, we can align our recycler view in a horizontal or vertical scrolling manner by specifying its orientation as vertical or horizontal. In Grid Layout manager we can align our recycler in the form of a grid.


3 Answers

I suggest you to use StaggeredGridLayoutmanager for your recycler view.

StaggeredGridLayout for RecyclerView

It's the closest approach to achieve your layout.

You can find the docs here. And working example can be found here.

like image 129
Aawaz Gyawali Avatar answered Sep 27 '22 17:09

Aawaz Gyawali


You can learn from this example which explain perfect about Recycler View

enter image description here

Hope this works for you

like image 27
Anshul Khare Avatar answered Sep 27 '22 17:09

Anshul Khare


Based on the type of bus choice, switch between GridLayoutManager, and StaggeredGridLayoutManager.

For all the types, use a header view with just a steering wheel icon right aligned.

  1. For the seater-only type:
    • use a 4 span GridLayoutManager
    • use an item decorator for providing the spacing between the 2nd and 3rd column
    • use a footer view with 5 seats view
  2. For the mixed-type:
    • use a 3 span StaggeredGridLayoutManager
    • use an item decorator for providing the spacing between the 1st and 2nd column.
    • use different item type for the sleeper seats (see: onCreateViewHolder(parent,viewType))
  3. For the sleeper-only type.
    • use a 4 span GridLayoutManager
    • use an item decorator for providing the spacing between the 1st and 2nd column
like image 20
Avinash R Avatar answered Sep 27 '22 17:09

Avinash R