Search Unity

Is there a way to make ListView / ScrollView change columns / rows with content size being updated ?

Discussion in 'UI Toolkit' started by Kaiymu_, Oct 9, 2019.

  1. Kaiymu_

    Kaiymu_

    Joined:
    Jun 1, 2016
    Posts:
    47
    Hello,

    I wanted to know if it would be possible that when the ListView / ScrollView resize, it's content would change the number of column / items inside it automaticly ?

    Just like that exemple :
    https://codepen.io/klamping/pen/WvvgBX?editors=1100

    (When you resize the view, the items change it's column / rows to fit the items inside).

    Right now I think I can manage to do it by code, but I think that's FlexBox in web already does it so !

    Thank you !
     
  2. patrickf

    patrickf

    Unity Technologies

    Joined:
    Oct 24, 2016
    Posts:
    57
    What the example shows is a side-effect of having padding and box-sizing=border-box. UIElements does not support box-sizing.

    Using

    .items {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    }
    .items .item {
    flex: 1 0 auto;
    min-width: 25%;
    }

    should achieve what you are looking for.