Forum Xamarin.Forms

Label Font Size Enhancements - Add Min/Max/Step for size

JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

Summary

Google has just introduced a new support library that enables TextView's to have min/max/step to auto re-size the text view for you. Once this is available it would be nice to introduce this into the Label class since iOS also has this functionality.

For reference; https://developer.android.com/preview/features/autosizing-textview.html

API Changes

In order to facilitate the new Font sizes api, 3 properties would be added to the Label class. This is done as a bool because it is simpler to data bind and other reasons...

var label = new Label ();
label.Text = "hello world"; 
label.FontSize = 16;
label.AutoFontSizeMin = 10; //new
label.AutoFontSizeMax = 100; // new
label.AutoFontSizeStepGranularity = 2; //new
label.AutoFontSizeType  = FontSizeType.Uniform; //options uniform or none

The MakeShiny API works even if the button is already visible.

Intended Use Case

When you want your label to no wrap, but want it to auto size.

Tagged:

Open · Last Updated

Posts

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    While I love that... I really miss the ViewBox from WPF that would scale all content, text images whatever, to the desired space. I guess i'm saying "Why mess with the font, when you can scale the entire control?"

    For what would probably be about the same man-hours to develop wouldn't that overcome multiple needs without risk of breaking existing Label, would work on more than just Android, wouldn't be affected by OS level settings of font size/scale etc. ?

Sign In or Register to comment.