Skip to content

sud.getContainerInfo ​

Synchronously gets OP container dimensions and the device pixel ratio for reading logical dimensions during game layout. Takes no arguments and does not return a Promise.

Return Value ​

Object

PropertyTypeDescription
containerWidthnumberLogical width, in dp on Android and pt on iOS
containerHeightnumberLogical height, in dp on Android and pt on iOS
pixelRationumberDevice pixel ratio; returns 1 when a valid ratio is unavailable

Usage Notes ​

  • containerWidth / containerHeight return the actual logical dimensions of the game container. Games are not always displayed in full screen (e.g., embedded or split-screen scenarios), so the container dimensions may be smaller than the screen dimensions. Therefore they are not interchangeable with screenWidth/screenHeight/windowWidth/windowHeight returned by sud.getWindowInfo; game layout and ad positioning should use container dimensions.
  • pixelRatio returns the device pixel ratio, which is consistent with the value returned by sud.getWindowInfo and can be used interchangeably.

Example ​

javascript
const { containerWidth, containerHeight, pixelRatio } = sud.getContainerInfo();

console.log('Container logical size', containerWidth, containerHeight);
console.log('Device pixel ratio', pixelRatio);

Using Dimensions with Banner ​

Banner's style.left/top/width/height, style.realWidth/realHeight, and onResize dimensions all use logical pixels. Use them directly without multiplying or dividing by pixelRatio. Pass the area actually reserved for ads by the game when calling sud.createBannerAd. See game developer examples for the complete flow.