Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change screen size #49

Open
ansarikhurshid786 opened this issue Oct 3, 2019 · 1 comment
Open

How to change screen size #49

ansarikhurshid786 opened this issue Oct 3, 2019 · 1 comment

Comments

@ansarikhurshid786
Copy link

In samsung setting there is option to change screen size or display size.

How can change screen size programatically ?

@newage99
Copy link

newage99 commented Feb 5, 2020

After trying this alternative and this alternative modifying directly cordova's android platform MainActivity.java without success, I discovered here that if you modify the zoom property of html body style, you can counter the zoom that display size applies.

In order to automatically detect the display size zoom applied, I've forked cordova-plugin-screensize into my repo and I've added displaySizeScaleFactor value to the get call, which gives you the factor of scaling that display size setting has applied.

First, add the plugin using:

cordova plugin add git+https://github.com/newage99/cordova-plugin-screensize

And then use this code after deviceready event has fired:

window.plugins.screensize.get(
  function(result) {
    document.body.style.zoom = (
      1.0 / result.displaySizeScaleFactor
    ).toString();
  },
  function() {}
);

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

No branches or pull requests

2 participants