在我的应用程序中禁用系统字体大小效果.

编程入门 行业动态 更新时间:2024-10-27 08:39:56
本文介绍了在我的应用程序中禁用系统字体大小效果. -C#-Xamarin.Forms Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不希望系统字体大小对我的应用程序有任何影响.如果我在android设置中增加系统字体大小,则我的应用程序中的文本将不可读. (太大.)我该怎么解决?

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:我正在用Xamarin.Forms项目的C#语言编写代码.

PS: Im writing my code in C#, Xamarin.Forms project.

谢谢

推荐答案

在我的应用程序中禁用系统字体大小效果

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(); ... }

更多推荐

在我的应用程序中禁用系统字体大小效果.

本文发布于:2023-10-07 01:30:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1468058.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字体大小   应用程序   效果   系统

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!