Hi guys. Is there a way to prevent user changes the fontsize?
I need the exact fontsize for label, button, listview and so on...
Any help? Thanks!
Just my perspective as a user: It's my device; I'll decide what size font I need in order for my 50 year old eyes to be able to read it. That's why there is a system-wide setting for this. When I choose to make the font larger than usual I accept that less data will be available on screen and that I'll have to scroll.
My perspective as a developer: Accept that the user owns the device, not me. They may change the theme, fonts, orientation, 3rd party theme tools, 3rd party font changers etc. Test the app through the range of default controls panels from small to large, dark and light. I'm responsible for it working through the expected operating conditions.
Ok. Thank you for your opinion. But you don't have answered my question XD
hat's how you do it in 2018 (Xamarin.Android/C# - same approach in other languages):
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
protected override void OnCreate(Bundle bundle)
protected override void AttachBaseContext(Context @base)
var configuration = new Configuration(@base.Resources.Configuration);
configuration.FontScale = 1f;
var config = Application.Context.CreateConfigurationContext(configuration);
All you need is override attachBaseContext method of activity and update config there.
getBaseContext().getResources().updateConfiguration() is deprecated though there're numerous examples with this method. If you use this approach besides the IDE warning you might find some parts of your app not scaled.
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies