Android Question CLV height

App Dude

Active Member
Licensed User
Longtime User
I confused about how to set the height of a custom list view.
In the designer, I have a panel which has a CLV on it. The panel serves as a visual border.
When I populate the list view, I want to increase the height based on how many items are in it, so all items are visible, and also increase the panel height.
The panel height increases as expected, but the CLV height does not. I'm using clv1.GetBase.Height = xxx.
I'm unclear when this isn't working.

I did read something about the CLV height being automatically set based on number and size of items added, but that does not seem to work correctly.
In the designer, I can increase/decrease the height of the CLV and it shows what I want, but I need to change it dynamically in code.
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I confused about how to set the height of a custom list view.
In the designer, I have a panel which has a CLV on it. The panel serves as a visual border.
When I populate the list view, I want to increase the height based on how many items are in it, so all items are visible, and also increase the panel height.
The panel height increases as expected, but the CLV height does not. I'm using clv1.GetBase.Height = xxx.
I'm unclear when this isn't working.

I did read something about the CLV height being automatically set based on number and size of items added, but that does not seem to work correctly.
In the designer, I can increase/decrease the height of the CLV and it shows what I want, but I need to change it dynamically in code.
I obviously don't fully understand your use case, but the whole point of a CLV is that is it scrollable.

If you are resizing ro fit its contents, then you run into the possible problem where the size of the CLV becomes too big for the size of the phone screen that it is running one.

I would normally set the CLV to the maxiumum size that works for the design and let it scroll its contents.
 
Upvote 0

App Dude

Active Member
Licensed User
Longtime User
So yes, I think I'm going about this the wrong way...

I originally had one screen with 3 panels and some buttons, and the third panel had a varying number of rows, so just that panel (CLV) scrolled.

Now, I changed it as shown below, so the whole section 0 (with panels 1,2,3) would scroll. To do this, I put a ScrollView in section 0, and loaded panel 4 into it, with panels 1,2,3 on panel 4. I need panel 3 to expand when there are more rows in there, and panel 4 to expand with it. I had moved the CLV (3) onto the new panel (4).

I'm in the middle of re-working it such that panel 4 can change length, and panel 3 would have a number of small sub-panels on it, rather than a CLV.

1665010368970.png
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Take a look at the "ResizingTextComponent" from this item.


I would have 4 as a CustomListview and 1,2,3 as resizing components. I do this sort of thing quite a lot in my code.

Also, take a look at this post. The last entry provides sample code.

 
Upvote 0

App Dude

Active Member
Licensed User
Longtime User
What I ended up doing is creating a new panel for each row in my list, and adding that to the specific Y position in panel 3. And I resized panel 3's height accordingly. (Onto each panel, I loaded a layout with the icon & text for each row).

That part works now :cool:, but I am now at a new point of confusion...

Later in the code, I need to change specific rows (change colors or text, etc) so I need the code to find a handle to specific panels. I'm not clear how to do this. :confused:
I can set a unique tag for each panel, but then what? Would I have to manually search all widgets on the whole screen and look for that tag? And still then what?
With the CustomListView I had before, I could use something like clv0.GetPanel(rowNumber).Color = Colors.Red
How would I get the panel now? Trying panel4.GetView(rowNumber).SetColorAndBorder(Colors.Red, 4dip, Colors.Yellow, 2dip) as a test, but it does not change anything visibly on the screen.
 
Upvote 0

App Dude

Active Member
Licensed User
Longtime User
I would have 4 as a CustomListview and 1,2,3 as resizing components. I do this sort of thing quite a lot in my code.

...

I hadn't thought about putting different-sized/shaped objects in a CLV. This might've been (and still may be) the better way to go about this.
 
Upvote 0
Top