Home » Android » android – What is the size, in pixels, of AdSize.BANNER?

android – What is the size, in pixels, of AdSize.BANNER?

Posted by: admin June 15, 2020 Leave a comment

Questions:

In my Android app, I have an AdView:

AdView adView = new AdView(this, AdSize.BANNER, MY_BANNER_UNIT_ID);

How do I get the size of this in pixels?

How to&Answers:

As mentioned in the answer by Flynn, an adView is 320 dp by 50 dp. To convert 50 dp to pixels, do

(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics());

(and similarly for 320 dp).

Answer:

You can use following methods from the AdSize class to get its size in pixels:

  1. getWidthInPixels(Context context),
  2. getHeightInPixels(Context content).

Answer:

An adView is 320×50, and if the view does not fit, then it is not displayed.

http://code.google.com/mobile/ads/docs/android/intermediate.html