Admob banner size for different devices

Just two days back, I came to know that SMART_BANNER is not the best for good CTR and we should dynamically switch between ad sizes for admob.

Here is the Java code, I have written. Do share what you think of it and if we can improve the code:

		AdSize adsize = AdSize.SMART_BANNER;
		Display display = getWindowManager().getDefaultDisplay();
		int width = display.getWidth();  
		int height = display.getHeight();
		int orientation = display.getOrientation();
		if(width >= 728 && height >= 90 ) {
			adsize = AdSize.IAB_LEADERBOARD;
			System.out.println("728 x 90");
		} else if (width >= 468 && height >= 60 ) {
			adsize = AdSize.IAB_BANNER;
			System.out.println("468 x 60");
		} else if (width >= 320 && height >= 50 ) {
			adsize = AdSize.BANNER;
			System.out.println("320 x 50");
		LinearLayout adContainer = (LinearLayout) findViewById(;
		adView = new AdView(this, adsize, "xxxxxxxxxx");
		AdRequest adRequest = new AdRequest();

		// Place the ad view.
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		adContainer.addView(adView, params);

Thanks for this thread. Very interesting. I’m using smart banners right now and it’s giving me less than 0.5% CTR.
Did this code improve you CTR?

As I told, I came to know about this 2 days back. Don’t have any first hand confirmation on this. But I think the reason is that, when users see bigger ads (on tv, intetnet or roads also), they tend to click or buy the stuff and hence increased ctr.

Well I use Admob mediation - and last I checked the SMARTBANNER was not available as an option. The banner appears in a constant size (dp-wise) on all devices - so banners are ultra small on tablets.

I am actually not that clear WHAT an Admob SMARTBANNER is - except that from Admob webpage that it is some “smart” as in color or size adjusted or extra space outside the banner is set to some color or what … (?)

If one were to scale the Admob banner ad (delivered via mediationID - if you are using Admob mediation) - then are all the partner banner ads ALSO scaled etc. (?) I guess this could be done and checked for the ad networks one is mediating (or is it that banner ads are somehow specified in some banner-agnostic way or something ?).

no. mediation only has support for 320 x 50. If you want access to other sizes, you need to switch to stand-alone mode. This I verified today only as one of my app was using mediation and when I specified IAB_LEADERBOARD, I got the error that received 320x50 and doesn’t match requested ad size.

Time to up my karma this Christmas.

Guys this method works amazing. My CTR and hence earnings have shot up 100% in last 15 days. The daily impressions are going same as on 8th December when I made this change. This code is recommended for everyone have java code for banners. For Unity and other softwares, you need to write the code yourself. The revised java code which is different from my first post is:

  AdSize adsize = AdSize.SMART_BANNER;
  DisplayMetrics dm = getResources().getDisplayMetrics();
  double density = dm.density * 160;
  double x = Math.pow(dm.widthPixels / density, 2);
  double y = Math.pow(dm.heightPixels / density, 2);
  double screenInches = Math.sqrt(x + y);
  if(screenInches > 8 ) {
  	adsize = AdSize.IAB_LEADERBOARD;
  } else if (screenInches > 6) {
  	adsize = AdSize.IAB_BANNER;
  } else {
  	adsize = AdSize.BANNER;
  RelativeLayout adContainer = (RelativeLayout) findViewById(;
  adView = new AdView(this, adsize, admobunitid);
  AdRequest adRequest = new AdRequest();
  // Place the ad view.
  adContainer.addView(adView, 0);

The ad sizes this code displays is:
>8 inches = 728x90
>6 inches = 468x60
<=6 inches = 320x50

Also if the ad cannot fit due to so varied android device sizes, setup and adlistener for executing code when ad cannot fit. Make current class as AdListener and add the following overridden method. Rest of the overridden AdListener methods can be left empty.

public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
adView = new AdView(this, AdSize.SMART_BANNER, admobunitid);
AdRequest adRequest = new AdRequest();


May Lord Jesus bless all of us, forgive us of all wrongful deeds (spamming, copying, abusing) that we have done in last year to earn money from android and may He help us live a spotless life with Android Development.

Thanks for sharing dude! I’ll definitely try that in a next update.
Just wanted to make sure of 1 thing: in your onFailedToReceiveAd, you basically load a default banner right?

Lol, Jesus is gonna be busy forgiving all of us sinners on this forum!!! May google bless you, with lots of green bank notes!

yes, if anything bad happens (due to android fragmentation) then we are showing SMART_BANNER whose height is less on bigger devices and is less noted by users. SMART_BANNER readjusts itself but not to 468x60 or 728x90

Great, thanks, I’ll try your code!

javaexp, could you say what CTR you had before and after using this code?

thats a wonderful share , thanks !

Read the dates on which I posted in this thread and compare with following data:

November overall ctr: 0.88%
December overall ctr: 1.87%
January till date overall ctr: 2.23%

attached december ctr graph


Thank for the info. In my apps I’m getting 1% CTR with the lowest refresh interval, so 2%+ is defenitly good. I’ll implement this code and post if my CTR goes up or not.

I’ve fiddled with this code for a while and sadly I can’t see any boost in revenue:(

Anyway I’ve notice that the screen size calculation in your code has a bug. On my SGS2 it returned 3.73 inches when in reality it was 4.23 inches. Here is the code that worked on my devices:

private double getScreenSizeInches() {
    DisplayMetrics dm = activity.getResources().getDisplayMetrics();

    double screenWidth  = dm.widthPixels / dm.xdpi;
    double screenHeight = dm.heightPixels / dm.ydpi;

    return Math.sqrt(Math.pow(screenWidth, 2) + Math.pow(screenHeight, 2));

Looks interesting

Your code wrong in Nexus 7 (6.7") or similar device. Tablet have system bar at the bottom and the height by display metric will not the real height.
This is my code:

		// Get screen size
		int screen_width = 480;
		int screen_height = 800;
        DisplayMetrics metrics = new DisplayMetrics();
		if (Build.VERSION.SDK_INT >= 11) {
	        Point size = new Point();
	        try {
	            screen_width = size.x;
	            screen_height = size.y;
	        } catch (NoSuchMethodError e) {
	            Log.i("error", "it can't work");
	            screen_height = this.getWindowManager().getDefaultDisplay().getHeight();

	    } else {
	        screen_width = metrics.widthPixels;
	        screen_height = metrics.heightPixels;
	    double x = Math.pow(screen_width/metrics.xdpi,2);
	    double y = Math.pow(screen_height/metrics.ydpi,2);
	    double screenInches = Math.sqrt(x+y);
	    Log.d("debug","Screen inches : " + screenInches);