SmartBanner height in real pixels for iOS and Windows Phone 8.x devices

502 views
Skip to first unread message

Anton Struzhkin

unread,
Jun 6, 2014, 12:12:39 AM6/6/14
to google-adm...@googlegroups.com
I need to make offset from top of the screen (where i have smartbanner) in my game for unity. As far SmartBanner always has height of 50 dp i am looking for formulas to convert it to device pixels. I found documentation for android (http://developer.android.com/reference/android/util/TypedValue.html#density) and use there formula:

Device Pixel Height = dp height * Screen.dpi / 160.0f
Screen.dpi - http://docs.unity3d.com/ScriptReference/Screen-dpi.html

Unfortunatly, this formula does not work for windows phone 8 and i think it won't work with iOS (not tested yet).
So how could i calculate device pixel heights for these two platforms? Or maybe my formula for android is also incorrect and i am just lucky with my devices that it works for them fine.

For admob i am using prime[31] plugin for unity to not deal with platfrom depended code. When i asked them about my problem they sent me here.

P.S. Sorry, for possible mistakes.

Eric Leichtenschlag

unread,
Jun 6, 2014, 5:34:22 PM6/6/14
to google-adm...@googlegroups.com
Smart banner is not always 50dp height. I don't remember what the thresholds are, but in practice, phones have 50dp height in portrait, 32dp in landscape, 7" tablets have 90dp height in portrait, 50dp in landscape, and 10" tablets have 90dp height in both orientations.

When laying out android apps via pixels, you need to multiply by density. iOS seems to handle that for you, so using the raw 32/50/90 value should be good enough. I'm not sure how WP8 works. 

Thanks,
Eric

Anton Struzhkin

unread,
Jun 6, 2014, 11:14:42 PM6/6/14
to google-adm...@googlegroups.com
Thank you Eric. Information about 50 dp was also from prime[31] support. I shode've check it. I've just decided to google as far as you was not confident about thresholds and I found this doc: https: "https://developers.google.com/mobile-ads-sdk/docs/admob/smart-banners?hl=en"
I don't see any size difference inside the tablet class as you mentioned. Could you find some other links?

пятница, 6 июня 2014 г., 14:34:22 UTC-7 пользователь Eric Leichtenschlag написал:

Eric Leichtenschlag

unread,
Jun 9, 2014, 4:33:00 PM6/9/14
to google-adm...@googlegroups.com
There won't be any specific documentation of it anywhere; it's based on internal implementation in the SDK. I've looked the thresholds up for you - currently the thresholds for 400dp device height for a 50dp height smart banner, and 720dp height for a 90dp smart banner. Smaller device heights will see the 32dp height ad. These thresholds probably won't change, but the SDK reserves the right to modify them.

Thanks,
Eric

Anton Struzhkin

unread,
Jun 10, 2014, 12:53:53 AM6/10/14
to google-adm...@googlegroups.com
Is it correct for both landscape and portrait orientations?

понедельник, 9 июня 2014 г., 13:33:00 UTC-7 пользователь Eric Leichtenschlag написал:

Eric Leichtenschlag

unread,
Jun 11, 2014, 6:39:00 PM6/11/14
to google-adm...@googlegroups.com
Yep, it depends on the device height in the current orientation. For example, an iPhone is 320x480. So in portrait, the ad will be 50 height because 480 > 400. In landscape, the ad with be 32 height because 320 < 400.

Thanks,
Eric
Reply all
Reply to author
Forward
0 new messages