1

How can I make screen size qualifiers for CSS files. Like app.css but for certain screen size like 10" tablets. If it's possible, can I also make Android specific like app.minWH720.android.css. It seems not to work, am I doing something wrong or is only xml supported.

I want to archive different label sizes on different devices. XML file are fine without touching them.

I'm aware of documentations like: https://www.nativescript.org/blog/details/supporting-multiple-screen-resolutions-in-your-nativescript-app

Terhoraj
  • 265
  • 4
  • 18
  • small add: could it be possible to get screen dpi value on start app.js and then use that to load specific app.css file. – Terhoraj Jun 21 '16 at 07:31

1 Answers1

1

Considering that you have screen qualifers pages like

main-page.minWH720.xml
main-page.minWH480.xml

You can simply provide different CSS classes for your XML elements.

.myButton-minWH720 {
   background-color: red
}

.myButton-minWH480 {
   background-color: blue
}

And use them accordingly where needed..

As for the second question you can get your metrics using the platform module like this in your app.js

var platform = require("platform");

var screen = platform.screen;

console.log(screen.mainScreen.heightDIPs);
console.log(screen.mainScreen.heightPixels);
console.log(screen.mainScreen.scale);
console.log(screen.mainScreen.widthDIPs);
console.log(screen.mainScreen.widthPixels);

var device = platform.device;

console.log(device.os);
console.log(device.manufacturer);
console.log(device.osVersion);
console.log(device.model);
console.log(device.sdkVersion);
console.log(device.deviceType);
console.log(device.uuid);
console.log(device.language);
console.log(device.region);
Nick Iliev
  • 9,610
  • 3
  • 35
  • 89
  • Hi Terhoraj. How did you get this to work? I create two xml files with one css file with different classes as shown above with different dpi numbers but was not able to get it to work. – jessiPP Oct 04 '17 at 07:29