This is a migrated thread and some comments may be shown as answers.

Make RadListView the height of the content

5 Answers 390 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 27 Apr 2017, 03:05 PM
Is it possible to make the RadListView the exact height of all the content when the rows are different heights? I have a RadListView in a ScrollView along with other controls. This works fine on both iOS and Android (API 21 or later). However, the content in each row can be a different height, so I can't simply set the height of the ListView equal to (row height * number of rows). Any thoughts would be helpful.

5 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 02 May 2017, 07:00 AM
Hello Ron,

Please have in mind that the RadListView has internal scrollview and its content can be easily scrolled, hence wrapping it in additional one is not recommended. You might want to reconsider the design of the application. Wouldn't it be better if navigation is used to visualize those different controls in a separate page instead of ScrollView?

If your case demand nesting scroll views, then you can try using the HorizontalOptions and VerticalOptions properties of the RadListView.
For example, if you set the VerticalOptions to Start and wrap the RadListView in a Grid layout, its height should be automatically calculated to be as high as the content or as high as it can get in the viewport.

It is difficult to suggest any specific implementation because I do not know the exact requirements but the suggested one is a good starting point.

Please give it a try, experiment with the suggested properties and let us know if you need any further assistance. 

Regards,
Pavel R. Pavlov
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ron
Top achievements
Rank 1
answered on 09 May 2017, 02:29 PM

Hi Pavel,

Thank you for the response. However, this does not solve my particular need. Let me explain a little more.

On both Android and iOS, it is perfectly acceptable to have a RadListView within a ScrollView. If you set the height of the RadListView to the exact height of the content, even older versions of Android (like API 19) handle it beautifully. The whole page scrolls exactly like you would expect, and you can have more than just the RadListView on the page.

If I knew the exact height of each row, I could simply set the height of the RadListView equal to the number or rows times the row height. However, I have rows that are different heights due to the content in each row.

So, I am looking for a way to set the RadListView's height to the exact height of all the rows, knowing that each row will have a different height. Simply wrapping it in a Grid, even with setting the VerticalOptions as you suggested, does not accomplish that.

Any other input would be greatly appreciated.

Thanks,

Ron

0
Tsvyatko
Telerik team
answered on 12 May 2017, 01:07 PM
Hello Ron,

Thank you for clarifying your particular scenario. You can force the listview to realize all its contents based on the parent view by accessing Android specific property through custom renderer. That way the listview will be forced to realize and measure all its cells thus  giving accurate result for its total size.

I have prepared sample project demonstrating how achieve the desired behavior through custom renderer.

Let us know if this helps.


Regards,
Tsvyatko
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ron
Top achievements
Rank 1
answered on 14 May 2017, 08:02 PM

Hi and thank you for your response! My app is for both Android and iOS. How could I accomplish this for iOS?

Thanks,

Ron

0
Tsvyatko
Telerik team
answered on 17 May 2017, 07:03 AM
Hi Ron,

The iOS listview does stretch automatically when nested inside scrollviewer. You can check the previously attached project and run it under iOS.

If you encounter any related issues do not hesitate to contact us.

Regards,
Tsvyatko
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Ron
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Ron
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or