AdMob banner sizes on Android

I am currently integrating AdMob into my Android game.

I have difficulty integrating smart banners into my framelayout-based layout because they take up different amounts of screen real estate on different devices.

For example, if I display a smart banner on my Acer A500 (MDPI 1280x800), I get one of the sizes 1280x90px, whereas on my Nexus 7 I get one with 1279x66px (TVDPI 1280x800) and on my Galaxy Nexus (HDPI 1280x720) with a resolution 1196x64 pixels.

According to the AdMob documentation, this can be an understandable behavior, given that the values ​​given in the documentation are dp: https://developers.google.com/mobile-ads-sdk/docs/admob/smart-banners

However, this behavior is a big problem for me, since a smart banner with a height of 90 pixels on an MDPI 1200x800px screen takes up much more screen real estate than a smart banner with a height of 64 pixels on an HDPI screen (see screenshots below).

So, here are my questions: - How much space should I reserve, at least for a smart banner? β€œHas anyone tried something like this, and how did you deal with this?”

Note. Unfortunately, using a layout other than framelayout is currently not an option. In addition, XML layouts cannot be used to integrate ads.

Best wishes,

Lorenz

Screenshots:

http://imgur.com/qGAk77Y (A500)

+6
source share
2 answers

If your layout is defined in xml, you can create one layout for each screen size (layout-xlarge / mylayout.xml, layout-large / mylayout.xml, layout-normal / mylayout.xml, etc.)

More information here: http://developer.android.com/guide/practices/screens_support.html

Do not look at density, because a 10.1-inch tablet has medium density, but a 4.3-inch phone with a resolution of 480x850 will have a high density. Instead, use a screen size (large large small size).

If you need to do this programmatically, you can get the screen size using this:

Configuration config = activity.getResources().getConfiguration(); int screenlayout = config.screenLayout; 

and for comparison use Configuration.SCREENLAYOUT_xxx.

+1
source
  • Do not think in terms of px. Think in terms of dp (density independent pixels).
  • Reserve the largest space. For example, 1280dp at 90pd using the containing layout and embed your AdView inside.
0
source

Source: https://habr.com/ru/post/950529/


All Articles