Make RadListView the height of the content

6 posts, 0 answers
  1. Ron
    Ron avatar
    18 posts
    Member since:
    Jan 2017

    Posted 27 Apr Link to this post

    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.
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1237 posts

    Posted 02 May Link to this post

    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
  3. Ron
    Ron avatar
    18 posts
    Member since:
    Jan 2017

    Posted 09 May in reply to Pavel R. Pavlov Link to this post

    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

  4. Tsvyatko
    Admin
    Tsvyatko avatar
    858 posts

    Posted 12 May Link to this post

    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
  5. Ron
    Ron avatar
    18 posts
    Member since:
    Jan 2017

    Posted 14 May in reply to Tsvyatko Link to this post

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

    Thanks,

    Ron

  6. Tsvyatko
    Admin
    Tsvyatko avatar
    858 posts

    Posted 17 May Link to this post

    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
Back to Top