In examples and tutorials, I've seen for xCustomListView, I see people just put in x dip as a value.
For example:
B4X:
Dim p As B4XView = xui.CreatePanel("")
p.Color = xui.Color_Black
p.SetLayoutAnimated(0, 0, 0, 100%x, 200dip) '<----- how do I determine what 200dip is supposed to be?
p.LoadLayout("ListViewItems")
My "ListViewItems" layout has a panel that contains all the items, for example maybe a EditText, Label, ImageView, and Button.
Something like this:
How do I determine that 200dip is correct? Do I add up all the heights of my items or something? Do I debug 10x and test different heights until I find something that fits?
Another thing is that after adding my item, there is a huge gap between items in my list. In the examples and tutorials I've seen, the items has a nice even gap between them
Usually I take the lowest items top plus its height plus hightest items top, but all your items are in a panel, so in this particular case, panel height + (panel top x 2)
Usually I take the lowest items top plus its height plus hightest items top, but all your items are in a panel, so in this particular case, panel height + (panel top x 2)
Because your first panel item is offset from the top of the panel you will likely need to add first panel items top to get an even layout.
Just think of the panel as the clv row. Use the panels height as the clv height. If you offset the top of the panel then add the offset x 2 to the panel height for the clv height. Note, to use this method, don't offset you controls from the top of the panel like you have in the picture
Just think of the panel as the clv row. Use the panels height as the clv height. If you offset the top of the panel then add the offset x 2 to the panel height for the clv height. Note, to use this method, don't offset you controls from the top of the panel like you have in the picture
In the designer genrate a reference to the panel so the app knows your panel height. It's the only way to refence the panel height otherwise regardless of loading the layout the app still can't access anything about the panel
In the designer genrate a reference to the panel so the app knows your panel height. It's the only way to refence the panel height otherwise regardless of loading the layout the app still can't access anything about the panel
The panel is part of the Layout for the CLV item. Until I load the layout, if I try to access the panel's properties, I will get an error : Object should first be initialized (Panel).
That is why I set the layout twice.
The anchor on my panel is set stretch left/right and top/bottom so there is no "Height" property. Maybe I will try setting the anchor to stretch left/right and vertical anchor to Top
I'll set the vertical anchor to TOP so that there is a height property so I can use it.
270 + (5 * 2) = 290dip
This looks MUCH better now.
I will try removing the panel as well, and try your method of the lowest items top plus its height plus (highest items top * 2)
Thank you so much for your wisdom
I see, so there are a few different ways to do it. I will play around with all of it.
The only thing is I have to figure out how to change the size if the text is too long for example.
Thank you for all your help!