Arr*_*row 1 c# android xamarin xamarin.forms
我不希望系统字体大小对我的应用程序有任何影响。如果我在android设置中增加系统字体大小,则我的应用程序中的文本将不可读。(太大。)我该如何解决?
PS:我用C#,Xamarin.Forms项目编写代码。
谢谢
在我的应用程序中禁用系统字体大小效果
如果需要为应用程序设置固定的文本大小,请尝试使用以下代码来实现此功能:
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();
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1014 次 |
| 最近记录: |