Giter VIP home page Giter VIP logo

hivelayoutmanager's Introduction

![Gitter](https://badges.gitter.im/Join Chat.svg)

HiveLayoutManager

这是一个蜂巢布局管理器,它可以在RecyclerView中实现像蜂巢一样的布局。

1 效果展示

横向布局:

纵向布局:

随机添加:

随机删除:

随机移动:

滚动:

2 使用方法

2.1 加入依赖

compile 'com.github.chacojack:hivelayoutmanager:1.0.1'

2.2 使用HiveLayoutManager

为RecyclerView设置HiveLayoutManager即可。其中包含横向和纵向两种方向。暂时只支持在初始化的时候设置方向,不支持后期改变。

recyclerView.setLayoutManager(new HiveLayoutManager(HiveLayoutManager.VERTICAL));

2.3 正六边形ViewHolder

ViewHolder使用的时候建议使用固定边长的正方形,这样比较好看。可以通过提供的HiveDrawable,将图片裁切为正六边形。HiveDrawable继承自Drawable,我们使用的所有视图都是View,使用View中的setBackground(Drawable background)即可为一个View设置正六边形背景。但是这种方法会让图片保持原有的大小,不会根据View的大小自动调整。所以建议使用一个ImageView来显示图片。

HiveDrawable drawable = new HiveDrawable(HiveLayoutManager.VERTICAL,bitmap);
imageView.setImageDrawable(drawable);

ViewHolder显示纯色背景:

drawable.setColor(resources.getColor(getRandomColor()));

纯色配文字的一个简单示例:

hivelayoutmanager's People

Contributors

chacojack avatar

Stargazers

 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.