Android Question [Solved] Resize CustomListView with a one long panel

asales

Expert
Licensed User
Longtime User
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
    15.5 KB · Views: 45

TILogistic

Expert
Licensed User
Longtime User
Are you using the Custom ListView for a single item?

And is this item taller than the visible area of the Custom ListView?

+++++++++++++


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
    4.3 KB · Views: 36
Last edited:
Upvote 1

PaulMeuris

Well-Known Member
Licensed User
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.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
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

asales

Expert
Licensed User
Longtime User
Are you using the Custom ListView for a single item?

And is this item taller than the visible area of the Custom ListView?
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

asales

Expert
Licensed User
Longtime User
The soluction to B4i is here:
"Make sure that the "handle resize event" option is unchecked in the item's layout file."
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…