事情就是这样,您可能知道 Admob 有一个AdSize.*
功能,您可以在其中Banner
显示横幅广告,而 AD_banner` 用于平板电脑横幅,我想做的是获取设备的屏幕尺寸,以便我可以将其放入我的如果声明,然后为正确的设备放置正确的横幅,我希望我足够清楚。所以任何人都可以告诉我如何获得设备的屏幕尺寸?谢谢你 ////////// 这是我到目前为止所做的
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
if (dm.density==DisplayMetrics.DENSITY_HIGH) {
AdView adView = new AdView(this, AdSize.BANNER,s);
LinearLayout layout = (LinearLayout)findViewById(R.id.admob);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
if (dm.density==DisplayMetrics.DENSITY_DEFAULT || dm.density==DisplayMetrics.DENSITY_LOW ) {
AdView adView = new AdView(this, AdSize.BANNER,s);
LinearLayout layout = (LinearLayout)findViewById(R.id.admob);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
if(dm.density==DisplayMetrics.DENSITY_MEDIUM)
{
AdView adView = new AdView(this, AdSize.IAB_BANNER,s);
LinearLayout layout = (LinearLayout)findViewById(R.id.admob);
layout.addView(adView);
adView.loadAd(new AdRequest());
}