question

Mrnin-6674 avatar image
0 Votes"
Mrnin-6674 asked Mrnin-6674 commented

Dynamic height for Xamarin Frame

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

dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I don't think it is a good idea to set the static height for the frame since you have a little bit more text in different device.

0 Votes 0 ·

1 Answer

JessieZhang-2116 avatar image
1 Vote"
JessieZhang-2116 answered Mrnin-6674 commented

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.




image.png (65.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I looked on the article about ListView appearance. Is it a way, how people manage diferent mobile resolutions ? I know, that in HTML/CSS, we use bootstrap and parameter class=" -sm -md -lg -xl". Is on mobile platform somethink like that as well, or Do I have to use Resize rows at runtime ? If there are otherways but they would be depracated in MAUI, its pointless to implement them.

0 Votes 0 ·