apmem / android-flowlayout Goto Github PK
View Code? Open in Web Editor NEWLinear layout, that wrap its content to the next line if there is no space in the current line.
Linear layout, that wrap its content to the next line if there is no space in the current line.
Such as the title
The title says all. Please prefix your attributes.
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
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>
Just try to add background color and you get java.lang.NullPointerException.
Pretty sadly...
Is it possible to add Gravity to your library. I want to align views from right.
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.
I'm trying to use the "flow layout" to group "TextView" but I'm having overlapping problem.
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?
What's the newest version in maven. I get 1.10, but not include FlowLayoutManager.
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);
}
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)
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 ?
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.
None of the logic for how the children will be laid out is visible to subclasses. Are there objections to making the lines member protected?
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!
http://developer.android.com/intl/zh-tw/reference/android/widget/RadioGroup.html
Android's RadioGroup extends LinearLayout.
It will let some items disappear when there are too many radio buttons.
Can you add this as a new feature?
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)
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
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
On the documentation we can use horizontalSpacing and verticalSpacing but there is no such attribute. Is the attributes removed intentionally?
When add children dynamically with drawable , it doesn't work well
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" />
When i import project into AndroidStudio, it promote this in "Messege" console.
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
It should use its parent's layout direction and fall back to the locale.
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
As mentioned in the subject, views are (or may be) cut off at the end of each line when using all-side (top/bottom/left/right) margins.
This can be reproduced by modifying the example app layout like this: http://pastebin.com/dvNpbrqz
I need to achieve such behavior:
Currently I do not know how to do it.
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.
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.
readme says all rights reserved, but there is also link to apache license.
So it is possible/simpler to build child views using the standard Android's Adapter pattern.
Other layout managers, such as LinearLayoutManager
, its subclass GridLayoutManager
, and StaggeredGridLayoutManager
have constructors that accept a Context
object "used to access resources ... when layout manager is set in XML by RecyclerView
attribute "layoutManager"
".
Add support for RecyclerView LayoutManager.
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>
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>
Can you push new performance commits for maven/gradle-support, please?
start
is always treated as left
and end
is always treated as right
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!
Would love to see a center justify option. I could help, but I'm not entirely sure which method to effect.
Hi, i only want to draw one row of views and now which view was the last painted one
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.
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?
<org.apmem.tools.layouts.FlowLayout
android:id="@+id/flowlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:layout_below="@+id/relLayoutSpinner">
</org.apmem.tools.layouts.FlowLayout>
Would it be possible to publish this to Maven Central?
Are there any plans to support full justification alignment? Has anyone worked out a way to implement full justification into a FlowLayout and would be willing to share thoughts/findings?
Full justification example: https://upload.wikimedia.org/wikipedia/commons/d/d9/State_of_the_union_word_clouds.png
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.