gpt4 book ai didi

android - Xamarin.Forms android - 调整控件大小以考虑辅助功能设置

转载 作者:行者123 更新时间:2023-11-29 16:45:13 25 4
gpt4 key购买 nike

在 Android 上,出于可访问性原因,用户可以设置更大的字体。

像这样的讨论会详细讨论命名或固定(数字)尺寸如何/是否会受到辅助功能设置的影响。

我有一个稍微不同的问题。有没有办法调整控件的大小以适应字体大小?对于我们的应用程序,如果用户在辅助功能下设置了较大的字体大小,那么按钮、Infragistics DataGrids、ListViews 等中的文本将不适合他们的控件。我错过了什么吗?

最佳答案

it's possible for the user to set a larger font for accessibility reasons.

您可以尝试使用以下代码来实现此功能:

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

Discussions like this one go into some details on how/whether the named or fixed (number) sizes are affected by accessibility settings.

不太明白你的意思,如果你的应用需要设置固定的文字大小,可以引用:

how to prevent system font-size changing effects to android application?

关于android - Xamarin.Forms android - 调整控件大小以考虑辅助功能设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48793995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com