Giter Site home page Giter Site logo

Comments (6)

thagikura avatar thagikura commented on May 4, 2024 1

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.

thagikura avatar thagikura commented on May 4, 2024 1

Fixed by #60
I'm going to include it in the next release.

from flexbox-layout.

thagikura avatar thagikura commented on May 4, 2024

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.

StylingAndroid avatar StylingAndroid commented on May 4, 2024

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.

thagikura avatar thagikura commented on May 4, 2024

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.

StylingAndroid avatar StylingAndroid commented on May 4, 2024

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)

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.