Skip to content

Accessibility Scaling Doesn't Work #19056

Closed

Description

@csnazell

Current behavior

Despite the documentation stating that Uno automatically scales text in response to accessibility configuration on Android and iOS. This is not happening on either the emulator or test device I am using.

I added the inverse of the disabling code linked above just in case it's now disabled by default to the app constructor to enable text scaling but it had no effect on observed behaviour.

Screenshots

At default text size:

Settings@Default

AppDraw@Default

TestApp@Default

At +2 text size:

Settings@+2

AppDraw@+2

TestApp@+2

Expected behavior

Displayed text should change size in response to accessibility configuration made in platform settings.

How to reproduce it (as minimally and precisely as possible)

Steps to reproduce:

  • created a new app from template.

  • build & deployed to Android Emulator (API level 35).

  • switched to Settings > Display Size and text.

  • adjusted Font Size slider to two places larger from the default.

  • switched back to the app.

  • there was no change in the displayed text.

  • switched to app drawer to confirm OS had changed it's default text size. It had.

  • deployed to device at API level 33 & it exhibited the same behaviour.

Demo project

UnoAppTest.zip

Workaround

N/A

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

N/A

Affected platforms

Android

IDE

Rider Windows

IDE version

JetBrains Rider 2024.3 (Build #RD-243.21565.191)

Relevant plugins

Runtime version: 21.0.5+8-b631.16 amd64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
.NET Core v8.0.4 x64 (Server GC)
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 16
Registry:
ide.experimental.ui=true
i18n.locale=
Non-Bundled Plugins:
com.intellij.resharper.HeapAllocationsViewer (2024.3.0)
com.jetbrains.rider.android (243.21565.191)
unoplatform (1.2.28)

Anything else we need to know?

N / A

Activity

  1. added
    difficulty/tbd
    kind/bug
    triage/untriaged
    on Dec 10, 2024
  2. jeromelaban commented on Dec 11, 2024

    @jeromelaban
    Member

    Thanks for the report. Font scaling is implemented here:

    var textSize = rawTextSize * (float)FontHelper.GetFontRatio();

    which gets its values from here:

    _cachedScaledDensity = displayMetrics.ScaledDensity;

    and
    _cachedScaledDensity = displayMetrics.ScaledDensity;

    it may be that some android devices don't provide that value properly, or that a change in android broke this feature.

    Can you try calling the ViewHelper.RefreshFontScale() method to see if this helps? I was able to get the font size to change when restarting the app. It may be that:

    private void RaiseConfigurationChanges()

    does not get called when the system size changes.

  3. csnazell commented on Dec 12, 2024

    @csnazell
    Author

    I can confirm stopping and restarting the app picks up the new scale value.

    I overrode OnConfigurationChanged() on the activity as follows:

    public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity
    {
        public override void OnConfigurationChanged(Configuration newConfig)
        {
            base.OnConfigurationChanged(newConfig);
            
            ViewHelper.RefreshFontScale();
        }
    }

    It's definitely getting called by Android (stops at a break point) so RaiseConfigurationChanges() should be being called. Manually calling ViewHelper.RefreshFontScale() has no effect.

    The newConfig object's .fontScale property reads 1.29999995 at the +2 notch on the scale (cf 1.0 at the default) so this detail is available to the app.

    Adding some additional debugging to investigate RefreshFontScale():

    public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity
    {
        public override void OnConfigurationChanged(Configuration newConfig)
        {
            base.OnConfigurationChanged(newConfig);
            
            ViewHelper.RefreshFontScale();
    
            // display metrics
            
            using Android.Util.DisplayMetrics displayMetrics = Android.App.Application.Context.Resources.DisplayMetrics;
            
            var debugScaledDensity = displayMetrics.ScaledDensity;
            var debugDensity = displayMetrics.Density;
    
            var debugConfig = FeatureConfiguration.Font.IgnoreTextScaleFactor;
            var debugConfigMaxScale = FeatureConfiguration.Font.MaximumTextScaleFactor;
    
            return;
        }
    }

    displayMetrics.Density = 2.625

    displayMetrics.ScaledDensity = 3.4124999

    FeatureConfiguration.Font.IgnoreTextScaleFactor = false

    FeatureConfiguration.Font.MaximumTextScaleFactor = null

    So _cachedScaleDensity should be the same as displayMetrics.ScaledDensity

    It looks like the UI isn't redrawing itself in response to these changes.

    Side note:

    There is a note in the Android docs indicating that the ScaledDensity field is deprecated as of API 34 (here}.

  4. added
    difficulty/medium 🤔
    and removed
    triage/untriaged
    difficulty/tbd
    on Sep 3, 2025
  5. changed the title [-]Accessibility Scaling Doesn't Work (Android)[/-] [+]Accessibility Scaling Doesn't Work[/+] on Sep 3, 2025
  6. MartinZikmund commented on Sep 3, 2025

    @MartinZikmund
    Member

    This feature needs to be implemented across all Skia targets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/medium 🤔kind/bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions