Search Unity

Changing List item height

Discussion in 'UI Toolkit' started by thelebaron, May 23, 2020.

  1. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    I'm trying to change the height of an element and while visually I can achieve this, it technically isn't working right as what the mouse selects still retains the previous height.



    Is changing the height at this element not the correct thing to do?

    upload_2020-5-22_20-3-38.png
     
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    ListView doesn't support multiple item heights. You'll need to use a ScrollView directly.
     
    thelebaron likes this.
  3. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    thanks, is this something that could happen later on down the line or is this just an incorrect assumption about how ListView should work?
     
  4. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    It's a limitation we are painfully aware of and we might support it in the future :)
     
    thelebaron likes this.
  5. silenterus

    silenterus

    Joined:
    Nov 8, 2019
    Posts:
    10
    mhhh

    Code (CSharp):
    1. listView.itemHeight = 300;
    works for me....
     
  6. f4bo

    f4bo

    Joined:
    Oct 7, 2014
    Posts:
    21
    I feel I'm experiencing something similar: I have a complex ListView element for 170px of fixed heigth but Unity clamp it at a smaller heigth, 44 pixels to be precise, as showed in the animated picture above. Seems to me, as showed below, that the UIToolkit is overriding any stylesheet settings for the heigth of any ListView element via the TemplateContainer wrapper, as the debugger shows clearly that the heigth is an inline value for each element, assigned dynamically by Unity's at runtime:



    and even if I try to override TemplateContainer class or any of the two associated selectors in the stylesheet, that doesn't work either, giving unpredictable results.
    Forgot to say I'm on 2021.3.20f1
     
    Last edited: Mar 14, 2023