Giter Site home page Giter Site logo

rockystevejobs / squarelayoutmanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iftechio/squarelayoutmanager

0.0 1.0 0.0 4.06 MB

小宇宙 App 广场组件,带惯性运动的二维矩阵卡片列表 UI,自定义 LayoutManager + SnapHelper

Kotlin 100.00%

squarelayoutmanager's Introduction

SquareLayoutManager

效果图

添加依赖

Add it in your root build.gradle at the end of repositories:

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

Add the dependency

dependencies {
      implementation 'io.iftech.android:SquareLayoutManager:<version>'
}

实现原理

小宇宙广场列表实现SquareLayoutManager

基本使用

设置 RecyclerViewLayoutManager

// 构造函数参数 spanCount为一行有多少个 ItemView,startPosition 为起始位置(不传默认中间)
rvSquare.layoutManager = SquareLayoutManager(20, 10)

滑动到指定位置:

layoutManager.smoothScrollToPosition(position) 

是否自动居中:

// 类似 LinearSnapHelper 效果,使用 fling 实现,默认为true
layoutManager.isAutoSelect = true

初始化布局时,是否定位到中心的 item:

// 默认为 true
layoutManager.isInitLayoutCenter = true

设置选中 Item 的监听回调:

layoutManager.setOnItemSelectedListener { postion ->
    Toast.makeText(context, "当前选中:$postion", Toast.LENGTH_SHORT).show()
}

滑动到中心:

layoutManager.smoothScrollToCenter()

squarelayoutmanager's People

Contributors

sinyu1012 avatar

Watchers

 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.