问题
I dont want to that system font size have any effect in my app. If i increase system font size in android settings, the text in my app will be unreadable. (Too big.) How can i solve it?
PS: Im writing my code in C#, Xamarin.Forms project.
Thanks
回答1:
Disable system font size effect in my App
If you need set a fixed text size for your application, you try using the following code to implement this feature:
private void initFontScale()
{
Configuration configuration = Resources.Configuration;
configuration.FontScale = (float)1.45;
//0.85 small, 1 standard, 1.15 big,1.3 more bigger ,1.45 supper big
DisplayMetrics metrics = new DisplayMetrics();
WindowManager.DefaultDisplay.GetMetrics(metrics);
metrics.ScaledDensity = configuration.FontScale * metrics.Density;
BaseContext.Resources.UpdateConfiguration(configuration, metrics);
}
protected override void OnCreate(Bundle bundle)
{
initFontScale();
...
}
来源:https://stackoverflow.com/questions/50289763/disable-system-font-size-effect-in-my-app-c-sharp-xamarin-forms-android