asales Expert Licensed User Longtime User Mar 6, 2026 #1 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. How can I fix it? Thanks in advance for any tips. Attachments CLVOnePanel.zip CLVOnePanel.zip 15.5 KB · Views: 136
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. How can I fix it? Thanks in advance for any tips.
LucaMs Expert Licensed User Longtime User Mar 6, 2026 #2 Changed layout2. You need to anchor the container panel (the one in the layout) top and bottom and make it as tall as the variant, no taller. Attachments CLVOnePanel.zip CLVOnePanel.zip 17.4 KB · Views: 124 Upvote 0
Changed layout2. You need to anchor the container panel (the one in the layout) top and bottom and make it as tall as the variant, no taller.
TILogistic Expert Licensed User Longtime User Mar 6, 2026 #3 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. Click to expand... 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) test: Attachments CLVOnePanel-test.zip CLVOnePanel-test.zip 4.3 KB · Views: 133 Last edited: Mar 6, 2026 Upvote 1
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. Click to expand... 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) test:
P PaulMeuris Well-Known Member Licensed User Mar 6, 2026 #4 And you could also try this from your code (added second and third line): Code: 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. Upvote 0
And you could also try this from your code (added second and third line): Code: 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.
TILogistic Expert Licensed User Longtime User Mar 6, 2026 #5 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. Upvote 0
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.
asales Expert Licensed User Longtime User Mar 7, 2026 #6 TILogistic said: Are you using the Custom ListView for a single item? And is this item taller than the visible area of the Custom ListView? Click to expand... Yes. Yes. It is a long form. I'm using ScrollView but now I try to port to B4i. This is why I'm using CLV. Thanks @LucaMs, @TILogistic, @PaulMeuris. The soluction of TILogistic works better in B4A and B4J. I'm get struggled with this code in B4i, but I'll post in the correct forum. Upvote 0
TILogistic said: Are you using the Custom ListView for a single item? And is this item taller than the visible area of the Custom ListView? Click to expand... Yes. Yes. It is a long form. I'm using ScrollView but now I try to port to B4i. This is why I'm using CLV. Thanks @LucaMs, @TILogistic, @PaulMeuris. The soluction of TILogistic works better in B4A and B4J. I'm get struggled with this code in B4i, but I'll post in the correct forum.
asales Expert Licensed User Longtime User Mar 7, 2026 #7 The soluction to B4i is here: Views Resize after Loading in CustomListView 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." Upvote 0
The soluction to B4i is here: Views Resize after Loading in CustomListView 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."