PagedGrid - Custom android view composed by multiple page grids with custom content and layout

Overview

API

PagedGrid

A PagedGrid is a ViewPager which pages are GridLayout with equal distributed rows and columns. This project is an Android library, written in Kotlin, that helps you create a PagedGrid component and manage its pages and cell views.

Motivation

This module provides a component with no added features, but a simple way to rapidly create particular Android views reducing the complexity, for example control panels, launchers and tables.

Getting started

Add the module as dependency using the latest version number, specified above.

Add the JitPack repository to your build file

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Version

Add the dependency using the latest version number, specified above.

dependencies {
    implementation 'com.github.arabello:PagedGrid:x.x.x'
}

It is possible to build the latest commit on the master branch, using the tag master-SNAPSHOT

dependencies {
    implementation 'com.github.arabello:PagedGrid:master-SNAPSHOT'
}

Usage

Notation: (ColumnIndex, RowIndex) [ColumnIndex, RowIndex]

Add the custom view to your layout

<io.matteopellegrino.pagedgrid.PagedGridView
    android:id="@+id/pagedGridView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Assign an instance of GridAdapter to the PagedGrid

val gridAdapter = GridAdapter(arrayOf())
pagedGridView.adapter = gridAdapter

Create an EmptyGrid page, specifying the number of columns and rows

val page1 = EmptyGrid(4, 5)

The page (grid) is a matrix of Element interface. DrawableIcon and BitmapIcon are ready to use implementation of Element. Add an element to the page using column and rows indexes.

page1[0, 2] = DrawableIcon("Photo Filter", R.drawable.ic_photo_filter_black_24dp)
page1[2, 2] = DrawableIcon("Portrait", R.drawable.ic_portrait_black_24dp)

You can create your own element just extending AbstractElement.

page1[1, 1] = object : AbstractElement() {
    override fun inflateView(parent: ViewGroup): View {
        val layout = LayoutInflater.from(parent.context).inflate(R.layout.custom, null)
        val img = layout.findViewById(R.id.img)
        val txt = layout.findViewById(R.id.txt)
        img.scaleType = ImageView.ScaleType.CENTER_CROP
        img.setImageBitmap(BitmapFactory.decodeResource(resources, R.mipmap.img_4))
        txt.setText(R.string.mytext)
        return layout
    }
}

Once pages are ready, add them (or assign) to the adapter and notify the changes.

gridAdapter.pages += page1
gridAdapter.notifyDataSetChanged()

The method setOnInflateViewListener allows you to access the cell View when created, extremely useful for attaching Android events. You can easily iterate over pages and cells (elements) as showed below.

gridAdapter.pages.forEach { page ->
    page.forEachIndexed { x, y, elem ->

        elem.setOnInflateViewListener { view ->
            view.setOnClickListener {
                Toast.makeText(baseContext, "View on ($x, $y) clicked", Toast.LENGTH_SHORT).show()
            }
        }
    }
}

For further details and specific uses case, please see the sample app

Personalization

Here the personalization properties (first value as default)

 <io.matteopellegrino.pagedgrid.PagedGridView
        app:animationEnabled="true|false"
        app:orientation="portrait|landscape"
        app:pageIndicatorUnselected="@android:color/gray"
        app:pageIndicatorSelected="@android:color/black" />

Animation

When the content of a page change and it is currently displayed, the component animates the transition to the new content as showed below.

Landscape

The landscape mode is supported, but it is severely rigid. The component is rotated clockwise only and the scroll becomes vertical. In this way

the coordinate of each element related to a page remain the same considering the top-left corner as the origin (0,0)

Credits

For the third party dependencies, thanks to

For the sample app illustrations, thanks to unDraw

License

MIT License
   
Copyright (c) 2018 Matteo Pellegrino
    
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
    
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
    
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...
[Development stopped in 2014. Unfinished and not stable - not recommended to use.] An easy-to-use ViewPager subclass with parallax background effect for Android apps.

Development stopped in 2014 Not developed since 2014. Unfinished and not stable - not recommended to use. ParallaxViewPager An easy-to-use ViewPager s

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Combine ViewPager and Animations to provide a simple way to create applications' guide pages.
Combine ViewPager and Animations to provide a simple way to create applications' guide pages.

WoWoViewPager WoWoViewPager combines ViewPager and Animations to provide a simple way to create applications' guide pages. When users are dragging WoW

Put some bubble in your tabs and give your apps a supa fresh style !
Put some bubble in your tabs and give your apps a supa fresh style !

BubbleTab Put some bubble in your tabs and give your apps a supa fresh style ! Usage Add a BubbleTab with your icons on the layout.xml Customisable pa

A pager for Android with parallax effect

ParallaxPagerTransformer A pager transformer for Android with parallax effect Installation in your build.gradle file dependencies { // ... com

Library containing common animations needed for transforming ViewPager scrolling for Android v13+.
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

ViewPagers library for Android

freepager Ready-to-use view pagers for your project. Based on Swipes navigation demo repository Usage: Gradle: dependencies { compile 'pro.alexza

Android library for fluid tablayout animation as seen on Snapchat.
Android library for fluid tablayout animation as seen on Snapchat.

SnapTabLayout Show some ❤️ and star the repo to support the project This library is the implementation of TabLayout as seen on popular messaging app S

Android auto scroll viewpager or viewpager in viewpager
Android auto scroll viewpager or viewpager in viewpager

Android Auto Scroll ViewPager ViewPager which can auto scrolling, cycling, decelerating. ViewPager which can be slided normal in parent ViewPager. Att

Owner
Matteo Pellegrino
Software Engineering
Matteo Pellegrino
Pixplicity 915 Nov 8, 2022
This project aims to provide a working page flip implementation for usage in ListView.

Changes: Made clickable views like a button clickable inside the FlipViewPager. Use RecyclerView. Updated to API 23. Added support for close clicks on

Yalantis 1.8k Dec 13, 2022
A Page Indicator Lib is realized in a different way.

#FlycoPageIndicator A Page Indicator Lib is realized in a different way. Support for Android 2.2 and up. ##Demo ####Here is a DemoApk download ##Gradl

Flyco 537 Dec 17, 2022
UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.

UltraViewPager 中文文档 ProjectUltraViewPager is a ViewPager extension that encapsulates multiple features, mainly to provide a unified solution for multi

Alibaba 5k Dec 20, 2022
Three material Dots Indicators for view pagers in Android !

Material View Pager Dots Indicator This library makes it possible to represent View Pager Dots Indicator with 3 different awesome styles ! It supports

Tommy Buonomo 2.8k Jan 5, 2023
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

ogaclejapan 7k Jan 1, 2023
Custom Tabs with Material Design effects

MaterialTabs Custom Tabs with Material Design animations for pre-Lollipop devices       Download example apk It requires 14+ API and android support v

Fabio Biola 1.4k Dec 29, 2022
A nicer-looking, more intuitive and highly customizable alternative for radio buttons and dropdowns for Android.

SwipeSelector Undergoing for some API changes for a 2.0 major version, see example usage in the sample module! What and why? Bored of dull looking rad

Iiro Krankka 1.1k Dec 9, 2022
Silver is a programming language designed to have the look and feel of python combined with the simplicity and efficiency of C, combined with a rich plugin system for extending the capabilities of the language

Silver Programming Language Silver is a programming language designed to resemble Python with some C features, packed with a rich plugin system. Contr

Silver Software 4 Jul 23, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 3, 2023