GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dimsob/FlowLayout: An Android Layout Manager to create a gridview with cells of different sizes inspired by Flow Layout for iOS.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
app
app
 
 
flowlayoutmanager
flowlayoutmanager
 
 
gradle/wrapper
gradle/wrapper
 
 
snapshots
snapshots
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

FlowLayout – Android Layout Manager

Download

A LayoutManager that must be used with RecyclerView inspired by Flow Layout for iOS.

The layout manager places cells on a linear path and fits as many cells along that line as it can. When the layout manager runs out of room on the current line, it creates a new line and continues the layout process there.

Compile

Using Gradle

Requires Min SDK version >= 10

    compile 'com.ch4vi.flowlayoutmanager:flowlayoutmanager:1.0.0'

Using Maven

    <dependency>
      <groupId>com.ch4vi.flowlayoutmanager</groupId>
      <artifactId>flowlayoutmanager</artifactId>
      <version>1.0.0</version>
      <type>pom</type>
    </dependency>

Usage

First of all add a RecyclerView to your layout

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/button_center"
        android:background="@color/e"
        android:scrollbars="vertical" />

Then in your class initialize the RecyclerView, in this case with 3 columns, vertical orientation and the first cell size will be 1x1, the second 2x2...

    val manager = FlowLayoutManager(3, RecyclerView.VERTICAL, object : FlowLayoutManager.Interface {
        override fun getProportionalSizeForChild(position: Int): Pair<Int, Int> {
            return when (position) {
                 0 -> Pair(1, 1)
                 1 -> Pair(2, 2)
                 2 -> Pair(4, 1)
                 3 -> Pair(3, 2)
                 else -> Pair(1, 1)
            }
        }
    })
    recyclerView.layoutManager = manager

Note If we add a cell too big for example if we have 3 columns and we add a cell 4x1, this cell will be ommited in the drawing process.

Optionally you can add a custom space between the cells adding a dimen resource named "default_card_insets" and setting an item decoration to your RecyclerView like in the example

    <dimen name="default_card_insets">8dp</dimen>
    recyclerView.addItemDecoration(manager.InsetDecoration(this))

Demo

Credits

  • Chavi Anyó
  • Álvaro Vilanova

License

FlowLayout is license under the Apache License.

About

An Android Layout Manager to create a gridview with cells of different sizes inspired by Flow Layout for iOS.

github.com/ch4vi/FlowLayout

Resources

Readme
Apache-2.0 license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.