Android implementation of FlowLayout. Layout arranges its children in multiple rows depending on their width.

Related tags

Layout FlowLayout
Overview

FlowLayout

FlowLayout is an opensource Android library that alows developers to easily integrate flow layout into their app. FlowLayout is an layout that display its children in multiple rows depending on their size.

Build Status Maven Central Android Arsenal

Example

Framed example screenshot Source code with examples is included in repository.

Dependencies

Gradle

compile "com.wefika:flowlayout:<version>"

Maven

<dependency>
    <groupId>com.wefika</groupId>
    <artifactId>flowlayout</artifactId>
    <version>[version]</version>
</dependency>

Usage

<com.wefika.flowlayout.FlowLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="start|top">

	<View
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Lorem ipsum" />

</com.wefika.flowlayout.FlowLayout>

License

Copyright 2013 Blaž Šolar

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.
Comments
  • remove android:allowBackup=

    remove android:allowBackup="true"

    This is conflicting with android:allowBackup in the app manifest.

    This error is shown:

    Error:Execution failed for task ':app:processDebugManifest'.
    > Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:16:9-36
        is also present at [com.wefika:flowlayout:0.4.0] AndroidManifest.xml:11:18-44 value=(true)
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:14:5-51:19 to override
    

    Tested on N5 running Android M Preview 2.

    opened by RyanRamchandar 7
  • FlowLayout not displayed in Android 4.2.2

    FlowLayout not displayed in Android 4.2.2

    Hi and thanks for all you have done. I used your FlowLayout mod, but it works perfectly on Android 2.2, 4.1 also, but on my N4 with 4.2.2, this is not displayed, and I do not know why. Precisely when displaying others views than Button.

    Hope you can help !

    Kind regards

    bug 
    opened by stackbase-zz 4
  • View doesn't re measure when chaning visibility of children

    View doesn't re measure when chaning visibility of children

    Hey there love the layout, it's super handy. Although I have one problem:

    When changing the visibility of the all layouts children to gone, then back to visible at a later time, the layout doesn't remeasure itself and stays flat. The layout is set to wrap_content so I can get it to hide, but it never returns. I'm using this functionality for a popup style of menu.

    Any help would be greatly appreciated.

    bug 
    opened by NialBruce 4
  • i get a class cast excepction?

    i get a class cast excepction?

    hi i get this error when i try to use the layout

    06-07 22:18:36.327  21398-21398/ian.marxbrothers E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: ian.marxbrothers, PID: 21398
        java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.view.ViewGroup$MarginLayoutParams
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5454)
                at com.wefika.flowlayout.FlowLayout.onMeasure(FlowLayout.java:109)
                at android.view.View.measure(View.java:17430)
                at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
                at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1083)
                at android.widget.LinearLayout.onMeasure(LinearLayout.java:615)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
                at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:453)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
                at android.view.View.measure(View.java:17430)
                at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
                at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
                at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
                at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
                at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                at android.view.Choreographer.doFrame(Choreographer.java:550)
                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                at android.os.Handler.handleCallback(Handler.java:739)
                at android.os.Handler.dispatchMessage(Handler.java:95)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5221)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    
    bug 
    opened by funianrun 3
  • Add FlowLayout from code

    Add FlowLayout from code

    I want to add some features to FlowLayout so I create a custom class and extends it from FlowLayout. then I need to instantiate it and add it to FrameLayout with addView. Is this possible or I should only use xml? I tried and nothing appeared in my screen. Thanks in advanced.

    bug 
    opened by mohgh 3
  • FlowLayout doesn't display when inside ScrollView

    FlowLayout doesn't display when inside ScrollView

    It seems like in some circumstances, FlowLayouts with android:layout_height="wrap_content" disappear when nested inside ScrollViews.

    The example below does not display properly, either on the device or in the Android Studio layout editor - the FlowLayout is hidden (looks like it has height 0). If the FlowLayout is given android:layout_height="50dp", it works (but defeats the purpose...). If the outer ScrollView is removed, making the LinearLayout the root, it displays properly.

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin">
    
    
            <com.wefika.flowlayout.FlowLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="start|top"
                android:minHeight="50dp">
    
                <Button
                    android:id="@+id/button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="New Button" />
    
                <Button
                    android:id="@+id/button1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="New Button" />
    
                <Button
                    android:id="@+id/button2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="New Button" />
    
                <Button
                    android:id="@+id/button3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="New Button" />
            </com.wefika.flowlayout.FlowLayout>
    
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello world" />
    
        </LinearLayout>
    </ScrollView>
    
    bug 
    opened by robinstark 3
  • What if only one child?

    What if only one child?

    I think I have found a bug when there is only one textview added from code to the layout with height= wrap_cotent, then layout will not show since the height is zero in onMeasure method.

    bug 
    opened by sduqlsc 2
  • Item show with animation

    Item show with animation

    Hi. First of all I would like to thank you such a great piece of code. Its really useful.

    I have a concern. I want to show the children/items of FlowLayout with animation. All the items should not animate together instead they should animate one by one in the order of their position. I want to apply scale animation on items.

    How can I achieve this? Please help me out

    Refer this video for reference. https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B08MbvYZK1iNTGRLb2Zud2RUNFE/animation-meaningfultransitions-hierarchicaltiming-4do_large_xhdpi.webm

    opened by niteshkhatri 1
  • Popular Android library badge

    Popular Android library badge

    I'm generating badges to highlight awesome open source Android libraries. They are ranked based on how many top apps the library is used in. If you would like to include it, I've added it to the README. If not, no problem, just close this. Let me know if you have any questions. Cheers!

    opened by libtastic 0
  • Flow layout Ignores padding when laying out children

    Flow layout Ignores padding when laying out children

    When a padding is applied to the actual flow layout, it appears to be ignored.

    The children in the far left position in column show be laid out at paddingLeft / paddingTop start position.

    <com.wefika.flowlayout.FlowLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/navigation_drawer_group_row_secondary" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="@dimen/margin_large" android:paddingRight="@dimen/margin_large" android:paddingLeft="@dimen/margin_large"> </com.wefika.flowlayout.FlowLayout>

    bug 
    opened by amchang 0
  • Improve GRADLE build Performance

    Improve GRADLE build Performance

    Parallel builds. This project contains multiple modules. Parallel builds can improve the build speed by executing tasks in parallel. We can enable this feature by setting org.gradle.parallel=true.

    Configuration on demand. Configuration on demand tells Gradle to configure modules that only are relevant to the requested tasks instead of configuring all of them. We can enable this feature by setting org.gradle.configureondemand=true.

    gradle caching. Shared caches can reduce the number of tasks you need to execute by reusing outputs already generated elsewhere. This can significantly decrease build times. We can enable this feature by setting org.gradle.caching=true.

    Gradle daemon. The Daemon is a long-lived process that help to avoid the cost of JVM startup for every build. Since Gradle 3.0, Gradle daemon is enabled by default. For an older version, you should enable it by setting org.gradle.daemon=true.

    ===================== If there are any inappropriate modifications in this PR, please give me a reply and I will change them.

    opened by hongdongni 0
  • Buttons are not adding as per the Flow layout behaviour

    Buttons are not adding as per the Flow layout behaviour

    I used Flowlayout in my application. Below is my code

    <com.wefika.flowlayout.FlowLayout android:id="@+id/flow" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="start" />

    then I adding the childview as buttons dynamically.Below is the code `FlowLayout ll = (FlowLayout)layout.findViewById(R.id.flow); for (int i = 0; i <= btnList.size; i++) {

              final Button btnTag = new Button(MainActivity.this); 
             btnTag.setId(3000 + i);
            FlowLayout.LayoutParams layoutParams = new FlowLayout.LayoutParams(
                   FlowLayout.LayoutParams.WRAP_CONTENT,FlowLayout.LayoutParams.WRAP_CONTENT);
              layoutParams.setMargins(7,7,7,7);
              btnTag.setTextColor(Color.BLACK);
    
              btnTag.setText("#"+btnList.get(i).toString());
              ll.addView(btnTag,layoutParams)
          }`
    
    1. Button width is not changing dynamically as per the text
    2. How to decrease Padding between button border and its text. How to resolve the above issues? Below is my screenshot screenshot_2016-08-13-19-33-09
    opened by venkymsnv 0
  • I think when the child‘s width is wrap_content we should add a condition,so the Measure mode is AT_MOST for child

    I think when the child‘s width is wrap_content we should add a condition,so the Measure mode is AT_MOST for child

            if(lp.width == LayoutParams.MATCH_PARENT) {
                childWidthMode = MeasureSpec.EXACTLY;
                childWidthSize -= (horizontalMargin);
            }
            // ****for  wrap_content condition 
            else if(lp.width == LayoutParams.WRAP_CONTENT){
                childWidthMode = MeasureSpec.AT_MOST;
                childWidthSize = sizeWidth-horizontalMargin-widthUsed;
            }
    
            else if(lp.width >= 0) {
                childWidthMode = MeasureSpec.EXACTLY;
                childWidthSize = lp.width;
            }
    

    after: screenshot_2016-06-28-14-56-56

    opened by JackLeeMing 1
GoolgePlusLayout is a custom layout that plays animation on the children views while scrolling as the layout in the Google Plus (android) main page

Google Plus Layout Google Plus Layout is a custom layout that support playing animation on child view(s) in a serialize manner like the the main

Ahmed Nammari 224 Nov 25, 2022
An Android layout for arranging children along a circle

CircleLayout An Android layout for arranging children along a circle You can customize the following options: cl_centerView: Set a specific view ID to

Francois Campbell 374 Nov 18, 2022
Added support to modify text size and indicator width based on the original TabLayout.

XTabLayout——可修改选中项字体大小和指示器长度的TabLayout XTabLayout是基于design包中的TabLayout进行了功能的扩展,在保留原有功能的基础上,增加了修改选中项字体大小、修改指示器长度以及限制屏幕显示范围内显示的Tab个数。 集成步骤: 1.添加XTabLayo

Kennor 660 Dec 20, 2022
FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

null 33 Dec 8, 2022
Linear layout, that wrap its content to the next line if there is no space in the current line.

Android flow layout Introduction Extended linear layout that wrap its content when there is no place in the current line. [] (https://travis-ci.org/Ap

Artem.Votincev 2k Jan 5, 2023
A customize multiple state layout for Android.

MultiStateLayout ?? A customize multiple state layout for Android. (中文文档) Preview Download the sample apk to see more: Sample APK. Setup Add the multi

Airsaid 10 Dec 26, 2022
Responsive Layout Gird Configuration using Compose. An adaptive layout

ResponsiveGrid Responsive Grid is most followed layout system by the designer as it adapts to screen size and orientation, ensuring consistency across

null 4 Apr 12, 2022
An Android demo of a foldable layout implementation. Engineered by Vincent Brison.

Foldable Layout This code is a showcase of a foldable animation I created for Worldline. The code is fully written with java APIs from the Android SDK

Worldline 599 Dec 23, 2022
This assignment gives you basically a post list and its detail with comments.🚀

Android Assignment ?? Description This assignment gives you basically a post list and its detail with comments. ?? Features Users can see random post

Okan AYDIN 31 Dec 20, 2022
An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu

ResideLayout An Android Layout which has a same function like https://github.com/romaonthego/RESideMenu. Can be used on Android 1.6(I haven't try it.)

Yang Hui 392 Oct 12, 2022
A very simple arc layout library for Android

ArcLayout A very simple arc layout library for Android. Try out the sample application on the Play Store. Usage (For a working implementation of this

ogaclejapan 1.4k Dec 26, 2022
Android layout that simulates physics using JBox2D

PhysicsLayout Android layout that simulates physics using JBox2D. Simply add views, enable physics, and watch them fall! See it in action with the sam

John Carlson 689 Dec 29, 2022
A 3D Layout for Android,When you use it warp other view,it can became a 3D view,一秒让你的view拥有3D效果!

ThreeDLayout A 3D Layout,When you use it warp other view,it can became a 3D view 中文文档 preview USAGE 1.compile library allprojects { repositories {

androidwing 490 Oct 27, 2022
It's an Android library that allows you to use Layout as RadioButton or CheckBox.

Android - CompoundLayout It's an Android library that allows you to use Layout as RadioButton or CheckBox. The librarie is Android 14+ compatible. Gra

null 483 Nov 25, 2022
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!

RecyclerRefreshLayout English | 中文版 RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout

dinus_developer 1.7k Nov 10, 2022
Easy, flexible and powerful Swipe Layout for Android

SwipeRevealLayout A layout that you can swipe/slide to show another layout. Demo Overview Drag mode Drag mode normal: Drag mode same_level: Features F

Chau Thai 1.5k Jan 4, 2023
[UNMAINTAINED]: AndroidMosaicLayout is android layout to display group of views as grid consists of different asymmetric patterns (90 different patterns).

AndroidMosaicLayout AndroidMosaicLayout is android layout to display group of views in more that 90 different patterns. What is AndroidMosaicLayout? I

Adham Enaya 474 Nov 12, 2022
Scalable Layout For Android

ScalableLayout for Android. Class: com.ssomai.android.scalablelayout.ScalableLayout 한글버전 README.md: https://github.com/ssomai/ScalableLayout/blob/mast

Youngmann Kim 273 Nov 21, 2022