Android Question Index height of a clv

Helio

Member
I might be missing something, but I can't see the last item in a CLV, even though they're fixed-size. The items are multiple views within a panel. I've looked extensively on the forum and haven't found a solution. Could anyone help? Note that I used a different height for the last item, but, besides not looking elegant, when the number of indexes is less than the height of the screen, there is a gray space below the last item.

B4X:
public Sub CreateListItem(Index As Int, NumItens As Int) As B4XView

  If Index<NumItens-1 Then
    Private mItemHeight As Int = 180dip
  Else
     Private mItemHeight As Int = 1.27*180dip
  End If
    ' Private mItemHeight As Int = 9*Label4.TextSize*GetDeviceLayoutValues.Scale'16%y*GetDeviceLayoutValues.Scale
 
  Dim p As B4XView = xui.CreatePanel("")
  p.SetLayoutAnimated(0, 0, 0, clvcompras.AsView.Width, 32%y)
  p.LoadLayout("XCLVcompras")
  Return p
End Sub
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
. . . there is a gray space below the last item.

I think that what you are seeing is the unused part of the CLV. I have written a demo based roughly on your code. The background of the added CLV items is a (default) grey, the background of the CLV (normally grey) I have changed to red, and the CLV is on a black panel.
 

Attachments

  • CLVDemo.zip
    10.5 KB · Views: 8
Upvote 0

Helio

Member
Thanks for the quick reply. I understand what you did, and thanks for the example. Maybe I didn't quite understand. The last item appears, but it's cut off. The image for my item is as follows:

Captura de tela 2025-09-20 150845.jpg


As you can see in the image below, the last item appears cut off. Not all of the item's labels appear.

ocr_screenshot_1758392690.PNG
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I have updated my example. There are two red buttons : one generates a short list of three items, the other a longer list of eight items. In both cases the final item is larger than the other items.

I cannot tell you what you are doing incorrectly because I cannot see your code. If you are still having problems try posting a short demo project.
 

Attachments

  • CLVDemo2.zip
    11 KB · Views: 1
Upvote 0

Helio

Member
Thanks for trying to solve my problem, but in my project, all items have the same height, and yet the last item appears cut off, regardless of how many items the list contains. Could it have something to do with the clv's internal scrollview? Something like clv.sv.height? Actually, I tested this and it worked for all items, without cutting off the last one, but it doesn't work for all screen sizes. I used the line: clvcompras.sv.Height=2*Label4.Height+170dip

This label4 is hidden in the layout where the clv is located and contains the height of an item. Actually, I found this value by trial and error, but as I said, it doesn't work for all screen sizes.
 
Upvote 0
Top