I tried several codes in the forum to resize a CLV after load a layout with a long panel, without success.
There are 3 labels in the long panel (top, middle and bottom) and I can't scroll the CLV to see the bottom label.
My example is in attach.
Are you using the Custom ListView for a single item?
And is this item taller than the visible area of the Custom ListView?
+++++++++++++
The typical problem when you have a single, very large item in a CustomListView is that the CustomListView incorrectly calculates the height when adding it, especially if you use LoadLayout or if the content changes afterward.
The safest solution is to add the panel, wait for the layout to calculate, and then resize the item.
This would cause CustomListView to recalculate the scroll area correctly.
B4X:
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0,0,0,clvTest.AsView.Width,clvTest.AsView.Height)
p.LoadLayout("layout2")
clvTest.Add(p,"")
Sleep(0)
Log(p.Height)
Log(panel1.Height)
clvTest.ResizeItem(0, panel1.Height)
And you could also try this from your code (added second and third line):
B4X:
clvTest.Add(CreateListItem(Root.Width, Root.Height),-1)
clvTest.ResizeItem(0,DipToCurrent(Root.Height))
' clvTest.ResizeItem(0,DipToCurrent(Root.Width)) ' in landscape orientation
The first item is resized.
I tested the code on my tablet and used the DipToCurrent to adjust the dip sizes.
In landscape orientation the width can be used in stead of the height.
Techniques used and learned when loading the design into an element and controlling the displacement in the visible area of the customlistview based on its size.
Hello all, Using a CLV in a B4i project I have some elements inside the items those must to be measured and adjusted to adapt the content. This question reflects on the CLV item panel height which is runtime calculated and adjusted. Some labels widths must to be adjusted also. The...
www.b4x.com
"Make sure that the "handle resize event" option is unchecked in the item's layout file."