Androidx fontscale not working on HuaWei Mate20 - android

I am using Androidx 1.1.0, when i override the "getResources()" function in my "AppCompatActivity" when i set the fontscale to 1.5f in the "getResources()" function, it does not work. And i change the androidx library to support library it works fine. Anyone get the same problem ?

First step open Huawei mate20 and click system settings
Second step, after entering the mobile phone system setting interface,click display.
Third step,after entering the display interface,click font and display size.
Step four, after entering the font and display size interface, you can see that adjusting the font size only adjust the font,display size adjusts the font,picture and other interface elements.
Step 5,here,adust the font size, and the display size can be set as required.

Related

Android Webview: Smaller Display Size Breaks Layout

I have an web app that's basically just displaying mobile website in an Android Webview, with some native bits for handling notification & navigation headers.
The issue is, when I change the Display Size setting (under Display) in an Android phone to anything smaller than Default, the content will be squeezed to the right side and left a blank space. I did a check with dev tool, and somehow the CSS's width is set to 66.67% of parent's by Android (in default it's 100%) & a minor left padding is also added. However, if the Display Size setting is larger than default, there is none / very minor style degradation.
The interesting part is when similar app is made in iOS (just display mobile site), there's no issue at all after changing the Display Size. So I'm pretty certain that the fix is limited to Android.
Is there any guidance to add code to anticipate these changes, or at least, completely disable the Display Size setting's effects?
*Edit:
What I've tried & failed:
Setting "width=device-width, initial-scale=1" in the website
Set loadWithOverviewMode and useWideViewPort to true
Combination of both of them
Solution is simple actually: there's a piece of old CSS code in the website that overrides CSS values when the width of the display is above certain threshold.

How to view preview of text size of user font in Android Studio?

When specifying text size on Android, the suggested the best practice is to use sp font units instead of dp, since with sp the text will increase/decrease in size according to the user's display preferences. For example, on my device I can go to
Settings -> Display -> Font
and choose a preference: small, normal, large, huge (these seem to vary across devices though).
Does anyone know a way to preview the effect of this preference in Android Studio's layout preview? It would be easier than having to deploy to a device/emulator in order to test. I can't see an option for this, but maybe I'm missing it.
Related: is there a standard multiplier for what the largest ("huge") font preference equals to? Or, can this even vary across devices? If there's no upper bound to how large the text could be, the first part of my question is probably moot.
As of about May 2020, This can now be done via the Layout Validation feature of Android Studio 4.0. This allows you to view different Font Sizes, devices and even see your layouts from the perspective of someone with color blindness.
No, there is no such way to preview the font scaling in the android studio as of now. but you can check out the material design for text scaling at < https://material.io/design/typography/the-type-system.html#type-scale > here you will some idea of how your text looks in runtime

Implementing zoom for all views in app via app settings

I have a following problem. In my App I have to implement a setting-feature that allows the user to set all font sizes and all views in the app bigger or smaller.
Dimensions of all my views are defined in sp's. So if the user goes to System-Settings and changes the FontSize all my views react on this.
Now I have to implement this feature, whithout changing the system settings.
I read this: android dynamically change style at runtime
and this: Android: application-wide font-size preference
but this can only manage all changes on TextViews and all other Views which are extending TextView like EditText, Buttons...
So my Question is: Is it possible to change the scale factor programmatically, which is used in SP?
Thanks in advance!
After some more googling I finally found a solution for my problem.
To change the scale factor I'm now using getResources().getDisplayMetrics().scaledDensity
I'm not sure if it works on all devices as it mentioned here: Read font size from Settings

Appcelerator webview android 5.x prevent system font size change

I have found a strange behavior of the application text size when I change the system font size settings on a Appcelerator Studio application.
In iOS and Android < 5.x it works fine. Always I can see fonts without scale. On Android 5.x text inside a WebView and other components like a AlertDialog or TextField, I notice a scaled font size. I want the app respect text size, prevent the OS settings change. I don't know why on Android 5.x don't have the same behavior. Is there a buy? or there are any configuration parameter to avoid this?
I try to get de size of an alert text trying to check the change buy It's no possible. If it not posible to avoid this at least should be something to check if system font size has changed and show an alert to the user.
I already try to set ti.ui.defaultunit on "dp" or other values with the same results.
The Label component don't change the font size in any case.
Thanks in advance.

How can I adjust the scale-independent pixel (sp) settings in the emulator?

I want to be using sp instead of dp for text in my application, in order to allow the user (according to the documentation) to scale the text for accessibility reasons. I need to test my layouts against this, to make sure there aren't any visual problems, such as text getting cut off or hidden. My problem is, I can't find any way to adjust this setting in the emulator or in any phone I have access to. What I'm looking for is something that would let me adjust system text size preferences so that my 12sp text would appear bigger in the application. How can I do this?
I believe there is no normal user-accessible preference. See this question on the Android stackexchange. This is from 2010 but things haven't changed since then afaik.
Ok, this answer was completely false. There are two options in Android 4 (ICS) to change the text size:
Settings -> Display -> Font size
This allows to set a general text size (small, medium, large, ..)
Settings -> Accessibility -> Large Text
Upscales all text entries
They both modify the same setting though, so when you enable Large text under accessibility, it changes the font size to huge.

Categories

Resources