Code Monkey home page Code Monkey logo

layoutmanager-flowlayout's Introduction

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

           

上面的示例图是我把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());

常见商品属性界面:

商品属性界面.gif

使用:见ProductActivity

常见悬浮商品属性界面:

商品属性界面.gif

使用:见SuspensionProductActivity

动画修复:

动画修复.gif

使用:见TextFlowActivity

viewpager中流式布局应用:

viewpager中流式布局.gif

使用:见ViewPagerActivity

1.1版本:

修复重复操作数据问题

1.2版本:

修复重复操作数据错位以及暴露内容高度

1.3版本:

修复中间添加数据时错位问题

1.4版本:

修复动画问题

gradle依赖:

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

dependencies {
        compile 'com.github.1002326270xc:LayoutManager-FlowLayout:v1.4'
}

欢迎大家提出问题,留言板留言或邮箱直接联系我。我会第一时间测试相关的bug

关于我:

email: [email protected]

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

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

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.