Screen

API Reference: Device.Screen

Screen is used to retrieve device display properties.

JavaScript
JavaScript
const Page = require("sf-core/ui/page");
const extend = require("js-base/core/extend");
const Screen = require('sf-core/device/screen');
var Page1 = extend(Page)(
function(_super) {
_super(this, {
onShow: function(params) {
Application.statusBar.visible = false;
this.headerBar.visible = false;
}
});
console.log("Device.Screen.dpi: " + Screen.dpi);
console.log("Device.Screen.width: " + Screen.width);
console.log("Device.Screen.height: " + Screen.height);
console.log("Device.Screen.touchSupported: " + Screen.touchSupported);
console.log("Device.Screen.orientation: " + Screen.orientation);
}
);
module.exports = Page1;

It is also possible to capture a screenshot with the Device.Screen.capture function.

JavaScript
JavaScript
const Page = require("sf-core/ui/page");
const extend = require("js-base/core/extend");
const Image = require('sf-core/ui/image');
const ImageView = require('sf-core/ui/imageview');
const Button = require('sf-core/ui/button');
const Color = require('sf-core/ui/color');
const Screen = require('sf-core/device/screen');
var Page1 = extend(Page)(
function(_super) {
_super(this, {
onShow: function(params) {
Application.statusBar.visible = false;
this.headerBar.visible = false;
}
});
var screenshot;
var myImageView = new ImageView({
width: 500,
height: 500,
backgroundColor: Color.BLACK,
});
this.layout.addChild(myImageView);
var myButton = new Button({
width: 100,
height: 100,
backgroundColor: Color.RED,
onPress: function() {
myImageView.image = Screen.capture();
}
})
this.layout.addChild(myButton);
}
);
module.exports = Page1;