Giter Site home page Giter Site logo

android-flowlayout's Introduction

Android flow layout

Introduction

Extended linear layout that wrap its content when there is no place in the current line.

Maven Central [Travis-CI] (https://travis-ci.org/ApmeM/android-flowlayout)

Demonstration

Orientation: HORIZONTAL, Gravity: FILL, LayoutDirection: LTR

Orientation: HORIZONTAL, Gravity: RIGHT & BOTTOM, LayoutDirection: RTL

Orientation: VERTICAL, Gravity: CENTER, LayoutDirection: LTR

Debug is switched off:

Installation and usage

Take from maven repository (http://search.maven.org/#search%7Cga%7C1%7Corg.apmem.tools, http://mvnrepository.com/search.html?query=org.apmem.tools) or add FlowLayout and other components to your solution

Add it as dependency in Gradle as:

compile 'org.apmem.tools:layouts:1.10@aar'

Or maven

    <dependency>
        <groupId>org.apmem.tools</groupId>
        <artifactId>layouts</artifactId>
        <version>1.10</version>
        <scope>provided</scope>
    </dependency>

Add the following xml code into your layout/something.xml:

<org.apmem.tools.layouts.FlowLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
>
</org.apmem.tools.layouts.FlowLayout>

To change default direction use the following code

android:orientation="vertical"

To change layout direction use the following code

xmlns:f="http://schemas.android.com/apk/res/your.namespace"
f:layoutDirection="rtl"

Android gravity now supported (in combination with elements weight):

    f:weightDefault="1.0"
    android:gravity="fill"

To override default spacing between elements use default android margins in the child View element:

android:layout_marginTop="32dip"
android:layout_marginRight="32dip"

Also if you need to break line before some object even if there is enough space for it in the previous line - use the following LayoutParameter in the child view element:

f:layout_newLine="true"

Detailed parameters

Layout parameters:

* android:orientation - line direction. Use one of the following values:

	* horizontal - line will be in horizontal direction, linebreak will create new line

	* vertical - line will be in vertical direction, linebreak will create new column

    * android:gravity - standard android gravity supported

* debugDraw - draw debug information

    * weightDefault - default weight value for child elements. Used to fill line in case of Gravity.FILL_HORIZONTAL | Gravity.FILL_VERTICAL

    * layoutDirection - direction of inner child elements:

            *  ltr - left to right direction

            *  rtl - right to left direction

Child layout parameters:

* android:layout_margin* - override default spacings

* android:layout_gravity - standard android gravity supported

    * layout_weight - weight of the element. If not specified "layout.defaultWight" is used.

* layout_newLine - break line before current element even if there is enough place in the current line.

Copyrights

Copyright 2011, Artem Votincev (apmem.org)

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.

android-flowlayout's People

Contributors

apmem avatar bugmaker avatar danielgindi avatar h6ah4i avatar hypest avatar jkmcnk avatar luoqii avatar michalrus avatar msya avatar naveedmurtuza avatar neoasket avatar patelatharva avatar seekting avatar thomasdelteil avatar zobnin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-flowlayout's Issues

Child margin is not accounted

Children's margin is not honored, only padding. So for example if I have the following:

<View 
....
android:layout_marginLeft="4dp"
...
/>

The 4dp is ignored in the actual layout

layout_gravity doesn't work in Child layout

sample:

<org.apmem.tools.layouts.FlowLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_gravity="end"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="hello"/>
</org.apmem.tools.layouts.FlowLayout>

the android:layot_gravity="end" in textview doesn't work.

ImageView LayoutParams is ignored.

FlowLayout seems to ignore LayoutParams' size. ImageView is always rendered according to source size instead of the size specified by LayoutParams.

E.g.
Image source size is 150x150.

ImageView imageView = new ImageView(activity);
imageView.setLayoutParams(new FlowLayout.LayoutParams(30, 30));

imageView measuredWidth, measuredHeight and width, height is 150 instead of 30.

Inflate Exception

The app is crashing on some device and this is the stack trace . I am using flowlayout inside relative layout with basic configuration , the xml code is attached below. Any ideas how to fix this.

Android version - Android 4.0.3 - 4.0.4
Device - Xperia Miro (ST23i)

android.view.InflateException: Binary XML file line #230: Error inflating class o.mz
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at com.oodles.download.free.ebooks.reader.fragments.BookDetailsFragment.onCreateView$469ccb8a(BookDetailsFragment.java:132)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:953)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1136)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1499)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManagerImpl.java:456)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
... 22 more
Caused by: java.lang.NullPointerException
at org.apmem.tools.layouts.LayoutConfiguration.getLayoutDirection(LayoutConfiguration.java:73)
at org.apmem.tools.layouts.FlowLayout.getLayoutDirection(FlowLayout.java:427)
at android.view.View.resolveLayoutDirectionIfNeeded(View.java:9633)
at android.view.View.getResolvedLayoutDirection(View.java:4826)
at android.view.View.setPaddingRelative(View.java:12034)
at android.view.View.setPadding(View.java:11945)
at android.view.ViewGroup.setPadding(ViewGroup.java:2378)
at android.view.View.(View.java:3108)
at android.view.View.(View.java:2735)
at android.view.ViewGroup.(ViewGroup.java:413)
at org.apmem.tools.layouts.FlowLayout.(FlowLayout.java:32)
at org.apmem.tools.layouts.FlowLayout.(FlowLayout.java:32)

<org.apmem.tools.layouts.FlowLayout
                android:id="@+id/container_tags"
                xmlns:flow="http://schemas.android.com/apk/res-auto"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/container_download_option"
                android:layout_marginTop="16dp"
                android:gravity="center"
                flow:weightDefault="1.0">
            </org.apmem.tools.layouts.FlowLayout>

Vertical alignment

Given the layout in horizontal mode, is there a way to vertically align children of different height?
E.g. choose between

*,  +,  ...
    +
    +
    +
*,  +,  ...
    +
    +
    +
*,  +,  ...

(* represents item 1, + represents item 2)

Dynamic textview won't honor LayoutParams and textAppearance

I've recently switched from a LinearLayout to this Flowlayout class. I add TextViews to the view dynamically and set them with textAppearanceLarge. This works for LinearLayout, but doesn't work for FlowLayout. I've found that if I add the TextView in the XML, it works - so it's something related to adding them dynamically to the FlowLayout.

Any suggestions?

Support for TextView and Edit Text

I tried your library with combination of TextViews and Edit Texts. TextView spans multiple lines followed by Edit Text and this can be followed by another Edit Text or Text View.

Example:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sed elit elementum, maximus tortor id, vulputate urna. Ut ultricies magna vel leo pretium rhoncus. __________________ Lorem ipsum dolor sit amet, consectetur _____________ __________________.

That is what I am trying to achieve. Do you think that can be done using your library ?

Need help with achieving described configuration.

I need to achieve such behavior:

  1. Horizontal FlowLayout contains several TextViews.
  2. It also contains EditText which is always in the end and occupies the whole width of the last line. So if in last line of TextViews they don't occupy the whole width then EditText occupies the rest otherwiase EditText moved to the next line (rarely possible).
  3. If during input EditText's text rather long to reach it's end then if it is the only view in line - it expands itself to the next line (default multiline behavior) if it is not then it's moved to the next line.
    Can this be done using this FlowLayout library?

2nd line isn't shown when using layout_height="wrap_content"

The following doesn't wrap correctly. It shows only what appears on the first line and truncates the rest. If I set an explicit height, it shows correctly.

            <org.apmem.tools.layouts.FlowLayout
                android:id="@+id/review_scores_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/spacing_small"
                android:layout_marginLeft="@dimen/spacing_large"
                android:layout_marginRight="@dimen/spacing_large"
                app:orientation="horizontal"
                >
                <TextView
                    android:id="@+id/review_service_score"
                    tools:text="Some Text Some Text"
                    style="@style/MyStyle"
                    />
                <TextView
                    android:id="@+id/review_responsiveness_score"
                    tools:text="Some Text Some Text"
                    style="@style/MyStyle"
                    />
                <TextView
                    android:id="@+id/review_professionalism_score"
                    tools:text="Some Text Some Text"
                    style="@style/MyStyle"
                    />
                <TextView
                    android:id="@+id/review_value_score"
                    tools:text="Some Text Some Text"
                    style="@style/MyStyle"
                    />
                <TextView
                    android:id="@+id/review_flexibility_score"
                    tools:text="Some Text Some Text"
                    style="@style/MyStyle"
                    />
            </org.apmem.tools.layouts.FlowLayout>

Allow to change attributes programmatically

Hi,

Currently it’s not possible to configure the layout programmatically, since orientation and friends are all private and there are no setters. Would be nice if there were setOrientation, setVerticalSpacing, etc.

HORIZONTAL SCROLL VIEW WITH FLOWLAYOUT

I mean i need FLOWLAYOUTui inside hoizontal scroll view so the labels doesnt go to next line and scrolls inside horizontal scroll view,kindly let me know is it possible

and other thing is i should be able to set the orientation
e183f768-9699-11e5-8d8b-b9456a222d08

FlowLayout with minHeigth

Hi ApmeM,
First of all thanks for your FlowLayout it solved some of my layout issues I were experiencing. Unfortunately it seems like the android:minHeigth property is ignored; is there any way to work around this?

This is how I currently use your FlowLayout:

<com.testapp.elements.FlowLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:minHeight="@dimen/verticalMarginBigger"
android:gravity="center_vertical"
app:orientation="horizontal"
app:weightDefault="1.0">

<!-- Here other views are added -->

</com.testapp.elements.FlowLayout>

Not sure about "installation"

Hello,

I've downloaded "layouts-1.0.apklib" from the provided Maven repository link (in the readme.md from this github you've written: "Take from maven repository ...")

Then I've added that apklib to my "libs" folder (myproject/libs) and then I've "added to build path".

After that I wanted to use the class FlowLayout but this didn't work:

   import org.apmem.tools.layouts.FlowLayout;

This works though:

  import org.apmem.tools.layouts.*;

But can't use "FlowLayout".

Whats happening?
I've opened the apklib with 7zip and the FlowLayout.java was there (not a .class though)

Custom drawable - rounded corners are lost with FlowLayout

Hi,

thanks for this helpful class!

I'm using it with a custom drawable and it works fine except that the buttons should have rounded corners. They do have them if put inside a different (regular android) layout but the FlowLayout seems not to honour the radius of the corners.

I have had a look at the FlowLayout source but I'm at a loss on how to solve this.

Here is the button layout xml:

<Button
    android:id="@+id/test"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="start|center_vertical"
    android:drawableStart="@drawable/abc_ic_clear"
    android:drawablePadding="5dp"
    android:text="Some Fancy Text"
    android:background="@drawable/button_green" />

And here is the definition of button_green:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false">
        <layer-list>
            <item android:radius="3dp" android:top="2dp">
                <shape>
                    <corners android:radius="3dp" />
                    <solid android:color="@color/button_shadow" />
                </shape>
            </item>
            <item android:bottom="2dp">
                <shape>
                    <solid android:color="@color/tag_green" />
                    <corners android:radius="4dp" />
                    <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
                </shape>
            </item>
        </layer-list>
    </item>
    <item android:state_pressed="true">
        <layer-list>
            <item android:bottom="2dp">
                <shape>
                    <solid android:color="@color/tag_green" />
                    <corners android:radius="4dp" />
                    <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
                </shape>
            </item>
        </layer-list>
    </item>
</selector>

Would you have some advice on how to fix this?
Thanks!

java.lang.IllegalArgumentException: Called attach on a child which is not detached

When i clicked the MANAGER TAB in the demo, i got crash stack like below.

10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: FATAL EXCEPTION: main
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: Process: org.apmem.tools.example, PID: 7638
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: java.lang.IllegalArgumentException: Called attach on a child which is not detached: ViewHolder{a66dbff position=0 id=-1, oldPos=-1, pLpos:-1 no parent}
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView$4.attachViewToParent(RecyclerView.java:587)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.ChildHelper.attachViewToParent(ChildHelper.java:239)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView$LayoutManager.attachView(RecyclerView.java:6492)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView$LayoutManager.attachView(RecyclerView.java:6507)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView$LayoutManager.attachView(RecyclerView.java:6518)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at org.apmem.tools.layouts.FlowLayoutManager.onLayoutChildren(FlowLayoutManager.java:63)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2847)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3145)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:493)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.View.layout(View.java:16630)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5437)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
10-20 12:32:01.470 7638-7638/? E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java

Margins between childs don't work

The next code does't make margins between textview. But it works in standard Layouts.

public void addWord2List(String word) {
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(30, 0, 30, 0);
        TextView tv = new TextView(this);
        tv.setLayoutParams(lp);
        tv.setText(word);
        tv.setTextAppearance(this, R.style.TextStyle);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
        tv.setTypeface(Typeface.MONOSPACE);
        tvList.add(tv);
        ((FlowLayout) findViewById(R.id.llWordsLists)).addView(tv);
    }

only paint one line

Hi, i only want to draw one row of views and now which view was the last painted one

Break before *this* element, only if line breaks at all

I suggest the following feature: Add an attribute for the childviews that indicates, that if (and only if) the line will break, break before this element.

Assume the following use case. I have a layout consisting of view A B A B. If the screen is wide enough, I would like to have them in one line. However, if there's not enough space, I want both the second A and B to be on the next line because

A B A
B

would look weird

max line issue

Hello!

i'm wondering if i can fix the max line of the widget?

i mean i don't want to extend more than 3 lines even if there are more items in the layout.

i just want to show items which are included in few lines and hide others.

i've tried fixing layout_height, but it didn't work.

< org.apmem.tools.layouts.FlowLayout
android:layout_width="match_parent"
android:layout_height="40dp" >
< ImageView android:layout_width="wrap_content" android:layout_height="30dp" android:src="@drawable/ic_addfollow" android:layout_margin="5dp" />
< ImageView android:layout_width="wrap_content" android:layout_height="30dp" android:src="@drawable/ic_addfollow" android:layout_margin="5dp" />
...
... (omit)
...
</ org.apmem.tools.layouts.FlowLayout>

thank you for reading my question .

Regards.

Center Justify

Would love to see a center justify option. I could help, but I'm not entirely sure which method to effect.

When RecyclerView layout_height set to wrap_content, there will be nothing show on the screen.

in FlowLayoutManager
this.config.setMaxWidth(this.getWidth() - this.getPaddingRight() - this.getPaddingLeft()); this.config.setMaxHeight(this.getHeight() - this.getPaddingTop() - this.getPaddingBottom()); this.config.setWidthMode(View.MeasureSpec.EXACTLY); this.config.setHeightMode(View.MeasureSpec.EXACTLY); this.config.setCheckCanFit(true);
setMaxHeight always get 0.
And when i set a exactly height in xml, the content can not scroll when the recyclerview is bigger than its parent.
Can you please tell how to solve this?
Thank you very much.

Support for save and restore state

First of all Thanks for the great library.
If I'm not mistaken flow layout doesn't support save and restoring view state. Could it be implemented in next releases? If there's a reason behind that I would be thankful to read that.
Cheers!

Layout Editor does not show all widgets properties

put a textView outside the FlowLayout, selected it, properties panel show Text,Hint,Text Color, etc.

move it inside FlowLayout, select it, properties panel does not show some of those properties anymore.

thank you.

draw children promblems

When add children dynamically with drawable , it doesn't work well
image

String[] gs = new String[]{"买车", "卖车", "订车", "车辆上牌", "车辆过户", "过户", "售后投诉处理"};

for (int i = 0; i < gs.length; i++) {
            TextView textView = new TextView(this);
            textView.setText(gs[i]);
            FlowLayout.LayoutParams params = new FlowLayout.LayoutParams(FlowLayout.LayoutParams.WRAP_CONTENT,
                    FlowLayout.LayoutParams.MATCH_PARENT);
            int m = DisplayUtil.dip2px(this, 10);
            params.setMargins(m, m, m, m);
            textView.setPadding(m, m, m, m);
            textView.setGravity(Gravity.CENTER);
            textView.setOnClickListener(goalListener);
            textView.setBackground(gray);

            System.out.println(gs[i] + " " + textView.getWidth());
            goal.addView(textView, params);
        }
 <org.apmem.tools.layouts.FlowLayout
    android:id="@+id/goal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="horizontal"
    android:padding="15dp" />

Child elements overlapping

I'm trying to use the "flow layout" to group "TextView" but I'm having overlapping problem.

See in the image:
captura de tela 2015-04-08 as 08 57 59

My layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:f="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:gravity="center_vertical">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="13:50"
                android:id="@+id/textView6"
                android:textSize="35sp"
                android:gravity="center" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="30 min"
                android:id="@+id/textView5"
                android:layout_gravity="center_horizontal" />
        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:text="Prog. 01"
                        android:id="@+id/tvProgramacao"
                        android:layout_weight="1" />
                </LinearLayout>

                <org.apmem.tools.layouts.FlowLayout
                    f:debugDraw="true"
                    f:layoutDirection="ltr"
                    android:gravity="left"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="D"
                            android:singleLine="true"
                            android:id="@+id/tvDomingo" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="S"
                            android:singleLine="true"
                            android:id="@+id/tvSegunda" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="T"
                            android:singleLine="true"
                            android:id="@+id/tvTerca" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="Q"
                            android:singleLine="true"
                            android:id="@+id/tvQuarta" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="Q"
                            android:singleLine="true"
                            android:id="@+id/tvQuinta"  />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="S"
                            android:singleLine="true"
                            android:id="@+id/tvSexta" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_margin="5dp"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:text="S"
                            android:singleLine="true"
                            android:id="@+id/tvSabado" />
                    </LinearLayout>
                </org.apmem.tools.layouts.FlowLayout>
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:padding="10dp">

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="1dp"
                android:layout_height="fill_parent"
                android:background="#ffffffff"
                android:layout_weight="1"></LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/imageView"
                android:src="@drawable/ic_filter_white_48dp"
                android:layout_gravity="center_vertical"
                android:layout_marginTop="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="5dp" />

        </LinearLayout>
    </LinearLayout>
</LinearLayout>

I'm forgetting some property?

Add Gravity

Is it possible to add Gravity to your library. I want to align views from right.

crash on devices of Sony series

12-18 02:28:50.665 E/AndroidRuntime( 2571): Caused by: java.lang.NullPointerException
12-18 02:28:50.665 E/AndroidRuntime( 2571): at org.apmem.tools.layouts.FlowLayout.getLayoutDirection(FlowLayout.java:410)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.View.resolveLayoutDirectionIfNeeded(View.java:9689)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.View.getResolvedLayoutDirection(View.java:4872)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.View.setPaddingRelative(View.java:12092)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.View.setPadding(View.java:12003)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.ViewGroup.setPadding(ViewGroup.java:2379)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.View.(View.java:3154)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.View.(View.java:2781)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at android.view.ViewGroup.(ViewGroup.java:412)
12-18 02:28:50.665 E/AndroidRuntime( 2571): at org.apmem.tools.layouts.FlowLayout.(FlowLayout.java:32)
12-18 02:28:50.665 E/AndroidRuntime( 2571): ... 28 more

Strange child width

Hey guys!

The lib is awesome and works fine in almost every cases. We found a string thing though.

screen shot 2015-03-23 at 2 10 50 pm

In a LG - E460 we found the linked isse. The cells are truncated even before they should be. By any chance do you know how I can solve this issue?

Thanks in advance!

Cheers

cant apply android:background tp FlowLayout

After Adding

android:background="@color/blue_800"

to FlowLayout, it gives this error:

12-16 15:51:31.959  25955-25955/com.efusionsoft.bookmyapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.efusionsoft.bookmyapp, PID: 25955
android.view.InflateException: Binary XML file line #2: Error inflating class org.apmem.tools.layouts.FlowLayout
        at android.view.LayoutInflater.createView(LayoutInflater.java:620)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at com.efusionsoft.bookmyapp.ui.fragments.Ques1.onCreateView(Ques1.java:27)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
        at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441)
        at android.view.View.measure(View.java:16497)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at android.view.View.measure(View.java:16497)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
        at android.view.View.measure(View.java:16497)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at android.view.View.measure(View.java:16497)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
        at android.view.View.measure(View.java:16497)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
        at android.view.View.measure(View.java:16497)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
        at android.view.Choreographer.doCallbacks(Choreographer.java:574)
        at android.view.Choreographer.doFrame(Choreographer.java:544)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5001)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at an

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.