Dynamic height for Xamarin Frame

Mrnin 26 Reputation points
2021-04-10T09:57:17.137+00:00

Hello, I ran into a problem with label that cant full fit into a Frame. I deployed my app on old phone with android 7 and resolution of 1200 × 600 or 960 × 480. Soo when the frame contain a little bit more text, which needs to be devide on two rows because of this resolution, the half of the text dont display. The frame has static height (HeightRequest) set by me. Because I use a CollectionView that generate the frames, I dont want to have a height of each frame diferent. Can I somehow achive a solution for this problem with minimal afford ?
Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
{count} votes

Accepted answer
  1. JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
    2021-04-14T03:39:41.477+00:00

    Hello,

    Welcome to Microsoft Q&A platform!

    The frame has static height (HeightRequest) set by me. Because I use a CollectionView that generate the frames, I dont want to have a height of each frame diferent.

    Since you have set a static height for the DataTemplate (yours is frame),then you have to set the special value for the frame which could wrap the different text of label (one line or two line based on different devices).

    So in this condition, you have to assign the exact value to the frame tested on your old phone so that it can display the text on two rows.

    But I don't think it is a good idea to do like this. If your string is variable, let's say it's fine on one phone, but not necessarily full text on another phone with a smaller screen.

    And CollectionView item is designed for having fixed size as well , you can do nothing in Forms project. So, if you set a fixed height for your frame item, then the short text which has only one line will have a line of blank.
    For example:

    87467-image.png

    In addition, you can check an official solution for Dynamic ListView Row Resizing : https://developer.xamarin.com/samples/xamarin-forms/UserInterface/ListView/DynamicUnevenListCells/


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful