resize text-size based on view's width/height

salmander

Active Member
Licensed User
Longtime User
Hi All,

My app works fine on my mobile phone, but today I installed it on another phone, which is lower resolution device.

All the views are aligned fine, however, the text on some views is only appearing partially, this makes sense, as the text is longer than the view's width. Can anyone please help me to find a solution to resize the text of a view based on the view's width.

Many thanks
 

thedesolatesoul

Expert
Licensed User
Longtime User
I think resizing the text size of the view is not the correct solution, but resizing the view itself.
How much text is there on the view? Is it possible to truncate it or set it as a marquee?
If there is too much text, maybe better to make it multi line and move the remaining layout downwards.
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
thanks @thedesolatesoul but I believe resizing the text (at least in some cases would work for me). As one of the place where I want to resize the text is listview. However, marquee does also sounds as a good option. Perhaps I will try both and see what suits me best. Can you help me with some coding please :D?

Cheers
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Well the code for MARQUEE and END is here

However if you follow the discussion it seems it might not work for a listview. Either way marquee on a listview will look quite horrible and distracting.

Also for measuring the width have a look at the code here although you will want to do some kind of recursive text reduction (so if text is getting cut off, decrease textsize and call the sub again). But this could go on until the text gets unreadable.
 
Upvote 0
Top