What I want is change the font size in a text view to fit all of content onto the page while being as large as possible. The text in it is also changing in length so just testing won't work. I also don't want it to have to scroll, but it is a multiline text view. This is in C# and I can't list anything I've tried because I am unsure as to where I should start.
Asked
Active
Viewed 40 times
0
-
https://stackoverflow.com/questions/3630086/how-to-get-string-width-on-android – Gusman Jun 08 '17 at 20:40
-
This seems like I could work this. Thank you and I will report back with results. – Student Jun 08 '17 at 20:41
-
@Gusman so I have tried this and it gives me the size but my question is how to get the fix so instead of getting current size how do I keep on increasing until full without a tedious loop. Also it is multi line so while this helped I'm unsure if it's a solution. – Student Jun 08 '17 at 20:47
-
Measure size -> free space? yes, increase font size and measure again : no, revert to previous font size and represent. – Gusman Jun 08 '17 at 20:49
-
Yes and while that would work, that would require a loop and I feel it would be resource and time wasting. Especially considering I will be resizing ~ every 10-30 seconds. – Student Jun 08 '17 at 20:54
-
And that's the only way to achieve it... There's no API that tells you the desired font size to get a text fit a size, I would love it as this is something I have done multiple times. – Gusman Jun 08 '17 at 20:56
-
@Gusman Ok thank you for the advice. I will now post my final code in the solution. – Student Jun 08 '17 at 21:04
-
Add it as an answer, tomorrow you can accept it as the solution. – Gusman Jun 08 '17 at 21:06
-
If you've found the solution to your problem you should post it as *an answer* not as an edit to the question. – Servy Jun 08 '17 at 21:11
-
https://stackoverflow.com/a/17786051/4984832 – SushiHangover Jun 08 '17 at 22:30