GithubHelp home page GithubHelp logo

yongshengluan / layoutmanager-flowlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xiangcman/layoutmanager-flowlayout

0.0 1.0 0.0 38.88 MB

快速利用RecyclerView的LayoutManager搭建流式布局

Java 100.00%

layoutmanager-flowlayout's Introduction

说真的自从对RecyclerViewLayoutManager有新的认识后,完全不用担心很多的复杂布局了。而且对ViewGroup测量过程也不用担心了,因为里面有LayoutManager帮我们实现了。下面就进入该篇文章的主题吧,废话不多说,直接上图更有说服力。

统一高度文本形式

RecyclerView-LayoutManager-Text.gif

不同高度文本行居中显示形式

RecyclerView-LayoutManager-DiffHeightText.gif

图片形式

RecyclerView-LayoutManager-Image.gif

上面的示例图是我把ItemView分别用了TextViewImageView。其实这些是没什么好说的,主要是如何定义这样的LayoutManager。相信大家都用过了LinearLayoutManager吧,系统提供的LayoutManager都是对齐的方式进行排版的,我们这里的flow的样式就是在排版item之前,判断了该行多余的空间还够不够显示,如果不够直接换行显示的思路。

使用:

详见TextFlowActivityDiffHeightTextFlowActivityPhotoFlowActivity

RecyclerView recyclerView = (RecyclerView) findViewById(flow);
FlowLayoutManager flowLayoutManager = new FlowLayoutManager();
//设置每一个item间距
recyclerView.addItemDecoration(new SpaceItemDecoration(dp2px(10)));
recyclerView.setLayoutManager(flowLayoutManager);
recyclerView.setAdapter(new FlowAdapter());

关于我:

email: [email protected]

简书: http://www.jianshu.com/users/7b186b7247c1/latest_articles

csdn: http://blog.csdn.net/u010429219/article/details/64915136

layoutmanager-flowlayout's People

Contributors

xiangcman avatar

Watchers

LYS 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.