Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore font-size setting changes for Cordova App when runs on Android 4.4+?

I've developed Cordova App with Cordova Version 3.6.3 and JQuery. The only one problem that i still can't get the best solutions is when i test my app on Android 4.4+ and there are users who love to change font size in setting > display > font-size of their device to be larger than normal. It causes my app layout displays ugly (the best display is when the font-size setting is normal only). But there is no effect of font-size setting for Android older than 4.4 (4.3,4.2...) So the app displays perfectly on older version.

The solutions that I've applied to my app is creating the custom plugin to detect configuration changed and it will detects if user uses Android 4.4+ and if they set font-size setting to anything that is not normal, I'll use JQuery to force font-size to the specified size.

Example is....

if (font_scale == huge)
{
    $("div").css("font-size","20px !important");
}

This works fine but sometimes after the page loaded, the css doesn't changes as I want. And suppose if there are 30 divs+ on that page so i must insert the statement like above 30 times and it takes too much time needlessly.

I just want to know, are there another ways to solve this problem that is easier than using this plugin? Maybe using some XML configuration or CSS3 properties that can makes my app displays properly without side effect from font-size setting of Android 4.4?

Another ways I also tried and it doesn't works are

  1. inserting fontScale on Androidmanifest.xml > activity tag
  2. inserting webkit-text-size-adjust:none; in css

I'd love to hear any ideas that help to solve this.

like image 391
Vicente Tentativa Avatar asked Oct 13 '14 08:10

Vicente Tentativa


People also ask

What version of Android is installed in my Cordova project?

To determine what version of Cordova's Android package is installed in your Cordova project, run the command cordova platform ls in the directory that holds your project. As a general rule, Android versions become unsupported by Cordova as they dip below 5% on Google's distribution dashboard.

How to set up and run Cordova/Ionic application on Android?

How to set up and run Cordova/Ionic Application on Android? Step 1: Go inside the Cordova project and open Android folder. Step 3. Add the required libraries like webrtc and socket in the project. properties file as shown below: cordova .system.library. 7 =org.webrtc:google-webrtc: 1. 0.

How to change the size of apps and text only in Windows?

But, you may want to change the size of the apps and text only in the main display. Here is how you can do just that: Click on the Start button in the bottom-right corner; Click on the gear icon; When the Settings menu shows up, click on Ease of Access; Next, click on Display located on the left

What Android API levels are supported by Cordova-Android?

See the Android SDK's System Requirements . Cordova's latest Android package supports up to Android API Level 28. The supported Android API Levels and Android Versions for the past few cordova-android releases can be found in this table:


1 Answers

So you just want to ignore the system font preferences. Here is the solution,I use MobileAccessibilty Plugin to ignore the system font preferences.

You just have to write following code in your onDeviceReady function in index.js

if(window.MobileAccessibility){
    window.MobileAccessibility.usePreferredTextZoom(false);
}

usePreferredTextZoom(false) will just ignore the system font preferences. :) :) :)

like image 151
Anuj.T Avatar answered Oct 01 '22 18:10

Anuj.T