changing admob banner size dynamically

橙三吉。 提交于 2019-12-04 09:53:29

If your layout is define in a xml, you can create one layout per screen size (layout-xlarge/mylayout.xml, layout-large/mylayout.xml, layout-normal/mylayout.xml, etc...)

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

Don't look at density, because, a 10.1" tablet has a medium density, but a 4.3" phone with a 480x850 resolution will have a high density. Use screen size instead (xlarge large normal small).

If you need to do it programatically, you can get the screen size with this :

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

and to compare, use Configuration.SCREENLAYOUT_xxx .

The most recent AdMob SDK includes AdSize.SMART_BANNER which enables the best size matched ad for the device.

I was using an older version myself and didn't knew about this feature :D

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!