question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clipped children when using `flexWrap="wrap"` and large width divider

See original GitHub issue

Issues and steps to reproduce

Below you can see a screenshot of a FlexboxLayout, which is clipping it’s children:

Screenshot_1576202779

The layout is defined as so:

<com.google.android.flexbox.FlexboxLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingVertical="@dimen/spacing_small"
    android:paddingEnd="@dimen/spacing_normal"
    app:dividerDrawableVertical="@drawable/vertical_spaced_divider"
    app:dividerDrawableHorizontal="@drawable/horizontal_spaced_divider"
    app:flexWrap="wrap"
    app:showDividerVertical="middle"
    app:showDividerHorizontal="middle"/>

The dividers are implemented like so:

vertical_spaced_divider.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="?android:attr/listDivider"
        android:left="16dp"
        android:right="16dp" />
</layer-list>

horinzontal_spaced_divider.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="?android:attr/listDivider"
        android:top="16dp"
        android:bottom="16dp" />
</layer-list>

Expected behavior

I expect the children to not be constrained horizontally, and the title text of each item stays on 1 line.

Each of the children has a width of wrap_context, so FlexboxLayout should be moving the item to the next line if there is not enough space.

If I remove the divider, the items are wrapped as expect.

Version of the flexbox library

2.0.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
chrisbanescommented, Dec 13, 2019

Having a quick look through the source, it looks like the dividers are taken into account for layout, but not when measuring children.

1reaction
vrabieandreeacommented, Nov 4, 2021

I’ve been dealing with the same issue. Would love to know when this gets merged as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mastering wrapping of flex items - CSS: Cascading Style Sheets
This means that if you have a set of flex items that are too wide for their container, they will overflow it.
Read more >
flex-grow - CSS-Tricks
The flex-grow property is a sub-property of the Flexible Box Layout module. It defines the ability for a flex item to grow if...
Read more >
How to make Flexbox items the same size - Stack Overflow
Or alternatively, you could use @Josh_Crozier's answer and conditionally set flex-wrap: wrap; when the browser window is below a certain width. This will...
Read more >
Divide Width - Tailwind CSS
​. Reversing children order ... If your elements are in reverse order (using say flex-row-reverse or flex-col-reverse ), use the divide-x-reverse or divide-y- ......
Read more >
Flutter Wrap Widget - Medium
Normally when you want to layout multiple widgets horizontally or vertically you can use a row or column. Row( children: [ MyWidget(), MyWidget ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found