Comments (6)
Sorry for the long delay.
During the course of replacing the existing LinearLayout with FlexboxLayout ( #59 ), I realized that attribute is useful in many situations.
I'm going to add this request to the queue of the upcoming implementation plan.
Probably in the form of layout_wrapAfter
or layout_wrapBefore
Thanks.
from flexbox-layout.
Fixed by #60
I'm going to include it in the next release.
from flexbox-layout.
Hi,
Thanks for your suggestion.
But I think having a explicit flag to indicate from which flex item the wrap should happen is not a way to go.
Because you don't have to nest ViewGroups to do so in the grid example above.
If you want to build a grid with the FlexboxLayout
you can put the grid cells as direct children of the FlexboxLayout
.
E.g. If you want make the first row having two cells, the second row having three cells and the third row having four cells, you can write a XML like below (omitting the not relevant attributes).
<com.google.android.flexbox.Flexbox
app:flexWrap="wrap">
<View app:layout_flexBasisPercent="50%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="50%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="30%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="30%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="30%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="25%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="25%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="25%"
app:layout_flexGrow="1">
<View app:layout_flexBasisPercent="25%"
app:layout_flexGrow="1">
</com.google.android.flexbox.Flexbox>
I think the layout above gives you the same result as you HTML as you pasted.
Instead if you want to give each flex item a fixed initial width and want to make the FlexboxLayout grow (have a new flex line) when a flex item doesn't fit in the current flex line, you can also do so like the example in the wiki
Having that flexibility is one of the big advantages of the Flexbox and I think adding a explicit flag to indicate from which flex item the wrap should happen loses that flexibility.
How do you think?
from flexbox-layout.
But that only works if you manually specify the percentages and can already be achieve efficiently on Android using PercentLayout
. Having the ability to control when wraps occur would make FlexboxLayout
totally unique for Android, and would open up many more use-cases which only FlexboxLayout
would provide an efficient solution.
from flexbox-layout.
Ok, I understand controlling when wrap occurs is equivalent to having fixed number of items in each grid row.
So I think it can be achieved by having different span counts on each row in a grid using GridLayoutManager like this.
Does that meet your requirement?
from flexbox-layout.
That would work, but would further compilicate an API which already isn't that intuitive for Android devs (alignItems vs. alignContent). That's the primary reason I'm suggesting what I am - increased control over internal behaviour via simple, understandable API additions.
However, any additions to the functionality which would facilitate flattened layouts for tabular data would be greatly welcomed by me ;-)
from flexbox-layout.
Related Issues (20)
- multi type adapter scrolling laggy
- Flexbox layout manager not scrollable
- indexInFlexLine is not consistent in onNewFlexItemAdded() method
- Android Studio Integration
- Add gap attribute HOT 3
- Wrong placement
- FlexboxLayoutManager.computeScrollOffset(); It is wrong to be equal to 0 HOT 1
- [FE] page 분기처리
- RecycleView nests RecycleView, and the internal RecycleView uses FlexboxLayoutManager(context, FlexDirection.ROW, FlexWrap.WRAP), when the number of items is large, it cannot be displayed completely (for example, only 30 items are displayed for 50 items, and they are not displayed after exceeding one screen) HOT 4
- ComposeView in flexbox crashes, because it is not attached when measured
- FlexboxLayoutManager child item margin is wrong when flex-direction is column
- How can i use this library in jetpack compose HOT 2
- Flaxbaox layout
- Playground doesn't build in latest Android Studio Flamingo HOT 3
- FlexboxLayoutManager does not recycle views with Navgraph HOT 3
- Is there possible to set "needsToFill" not only mContext.getResources().getDisplayMetrics().heightPixels?
- java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1 HOT 1
- FlexBoxLayoutManager with RecyclerView causes multiple items to refresh on calling notifyItemChanged
- First party support for Compose UI
- eid=2f746627-
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexbox-layout.