简体   繁体   English

为Google DFP广告管理系统缩放到不同的Android屏幕尺寸-Phonegap

[英]Scaling to different android screen size for google DFP ad - Phonegap

I'm working on developing an android app for our business website using Phonegap. 我正在使用Phonegap为我们的商业网站开发android应用。 Instead of splashscreen, we need to use a Google DFP creative prodided by our advertiser. 我们需要使用广告客户提供的Google DFP广告管理系统来代替启动屏幕。

Issue with it is, The Google DFP loads successfully but it is not scaling even after trying our different 'meta' tag options. 问题在于,Google DFP广告管理系统可以成功加载,但即使尝试了不同的“元”标记选项也无法缩放。

1) meta id="testViewport" name="viewport" content="user-scalable=yes, initial-scale=1,maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" 1)meta id =“ testViewport” name =“ viewport” content =“ user-scaleable = yes,initial-scale = 1,maximum-scale = 1,minimum-scale = 1,target-densitydpi = device-dpi”

2) meta id="testViewport" name="viewport" content="user-scalable=no, initial-scale=1,maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" 2)meta id =“ testViewport” name =“ viewport” content =“ user-scalable = no,initial-scale = 1,maximum-scale = 1,minimum-scale = 1,target-densitydpi = device-dpi”

3) meta id="testViewport" name="viewport" content="initial-scale=1,maximum-scale=1, minimum-scale=1 3)meta id =“ testViewport” name =“ viewport” content =“ initial-scale = 1,maximum-scale = 1,minimum-scale = 1

and also various other combinations. 以及其他各种组合。

Also, tried by adding a javascript script function that sets DFP's height and width at runtime but turned out to be unsuccessful. 另外,尝试添加一个JavaScript脚本函数,该函数在运行时设置DFP的高度和宽度,但结果不成功。

Many Thanks in advance!!! 提前谢谢了!!!

Finally resolved this... Logic is to get the screen size of the device and calculating the target scaling value based on device orientation. 最终解决了这个问题...逻辑是获取设备的屏幕尺寸并根据设备方向计算目标缩放值。 This code has to be added in 'onCreate' method. 此代码必须在“ onCreate”方法中添加。

 // get actual screen size
        Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int height = size.y;

// calculate target scale (ORIG_APP_W is max width of image, ORIG_APP_H is max height of image)
        double globalScale_Width = Math.floor( ( width / ORIG_APP_W ) * 100 );
        double globalScale_Height = Math.floor( ( height / ORIG_APP_H ) * 100 );

 // set the scale based on orientation
        if(deviceOrientation==getResources().getConfiguration().ORIENTATION_PORTRAIT){
            super.appView.setInitialScale( (int)globalScale_Height);
        }else if(deviceOrientation==getResources().getConfiguration().ORIENTATION_LANDSCAPE){
            super.appView.setInitialScale( (int)globalScale_Width);
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM