FlowLayoutManager is a layoutManager that works with Android RecyclerView Widget, to layout views in flow style, with support of predictive animations, item per line limit, auto measurement & alignments (left or right)
Add following to your build.gradle dependencies section
compile 'com.xiaofeng.android:flowlayoutmanager:1.2.3.2'
recyclerView.setLayoutManager(new FlowLayoutManager());
No setup needed, when data changed, do not use notifyDatasetChanged, which will skip all animations, but use notifyItemXXX APIs, those APIs will trigger animations.
Single item per line
recyclerView.setLayoutManager(new FlowLayoutManager().singleItemPerLine());
or x items per line
recyclerView.setLayoutManager(new FlowLayoutManager().maxItemsPerLine(x));
to remove Item per line limitation
((FlowLayoutManager)recyclerView.getLayoutManager()).removeItemPerLineLimit();
FlowLayoutManager flowLayoutManager = new FlowLayoutManager();
flowLayoutManager.setAutoMeasureEnabled(true);
recyclerView.setLayoutManager(flowLayoutManager);
recyclerView.setLayoutManager(new FlowLayoutManager().setAlignment(Alignment.LEFT));
Alignment could be LEFT or RIGHT.
Copyright 2016 Xiaofeng Han
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.