Phonegap - Ignore font-size display setting on And

2020-02-26 08:50发布

I'm having an issue with some android devices when changing the font-size display setting through configuration.

In web browser my app is simple ignoring this. This is true for some other mobiles too.

But with some specific mobiles (like Motorola G or X) changing this config also affects my Phonegap app.

I don't know how to avoid this to make the app look consistent

2条回答
Bombasti
2楼-- · 2020-02-26 09:33

For anyone using Ionic. Documentation is here.

Install

$ ionic cordova plugin add phonegap-plugin-mobile-accessibility
$ npm install --save @ionic-native/mobile-accessibility

Add to module, i.e. app.module.ts

import { MobileAccessibility } from 'ionic-native';


@NgModule({
    providers:[MobileAccessibility]
});

In app.component.ts

constructor( mobileAccessibility: MobileAccessibility, platform: Platform) {

    platform
      .ready()
      .then(()=>{
          mobileAccessibility.usePreferredTextZoom(false);
      });

}
查看更多
三岁会撩人
3楼-- · 2020-02-26 09:53

I've found a solution using this cordova plugin: com.phonegap.plugin.mobile-accessibility

You have to follow installation instructions for the plugin, and then you can use it inside Ionic app. You only have to ensure to call its functions after Cordova 'deviceready' callback (accesed by $ionicPlatform.ready in the example below):

angular.module('app').controller('IndexController', function ($ionicPlatform, $window) {

    $ionicPlatform.ready(function(){
        if($window.MobileAccessibility){
            $window.MobileAccessibility.usePreferredTextZoom(false);
        }
    });
});
查看更多
登录 后发表回答