Giter Site home page Giter Site logo

xiaomaguoguo / staggeredgridview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maurycyw/staggeredgridview

0.0 2.0 0.0 161 KB

A modified version of Android's experimental StaggeredGridView. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.

Home Page: https://github.com/maurycyw/StaggeredGridViewDemo

staggeredgridview's Introduction

StaggeredGridView

Introduction

This is a modified version of Android's experimental StaggeredGridView. The StaggeredGridView allows the user to create a GridView with uneven rows similar to how Pinterest looks. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.

Setup

To use StaggeredGridView in your projects, simply add this project to your workspace then add it as a library project to your current project.

Usage

StaggeredGridView can be added as a custom view to any layout.

Attributes supported (same behavior as GridView):

  • numColumns : determines the amount of columns to be drawn
  • drawSelectorOnTop : determine if selector should be drawn on top
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:staggered="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/mainLayout">

    <com.origamilabs.library.views.StaggeredGridView
        android:id="@+id/staggeredGridView1"
        staggered:numColumns="2"
        staggered:drawSelectorOnTop="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

The StaggeredGridView includes its own interface's OnItemClickListener, and OnItemLongClickListener since StaggeredGridView does not extend an AdapterView. Behavior is the same.

onItemClick(StaggeredGridView parent, View view, int position, long id);

onItemLongClick(StaggeredGridView parent, View view, int position, long id);

Tests

No tests have been written however I have tested this View manually with 2.2.2+ devices. Please report any issues.

TODO:

  • implement more custom attributes to mirror GridView's attributes
  • develop tests
  • hideSelector()
  • support multiple choice mode
  • currently restoring position can result in the views to be slightly offset when user flings to the top. This is corrected by checking the offsets when position 0 is reached. Would like to dig deeper into the issue.

staggeredgridview's People

Contributors

maurycyw avatar tbruyelle avatar vinc3m1 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.