遵循此代码(https://developers.google.com/mobile-ads-sdk/docs/admob/advanced):
import com.google.ads.*;
public class BannerExample extends Activity implements AdListener {
private InterstitialAd interstitial;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the interstitial
interstitial = new InterstitialAd(this, MY_INTERSTITIAL_UNIT_ID);
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(this);
}
@Override
public void onReceiveAd(Ad ad) {
Log.d("OK", "Received ad");
if (ad == interstitial) {
interstitial.show();
}
}
}
我的图像(我的广告)小于我的手机屏幕。
我想知道是否可以调整创建到java代码中的视图的大小。 (在onCreate()
或onReceiveAd()
中)用于调整广告的大小。
LayoutParam,在CenterCrop中,例如,或者简单地调整视图大小!
答案 0 :(得分:2)
如果您要将DFP广告管理系统中的插页式广告投放到手机,则可以在DFP广告管理系统中设置图片,并将尺寸覆盖为320x480。然后,该广告可以投放,如果您愿意,可以更小。
或者,您可能正在寻找横幅而不是占据整个屏幕的插页式叠加层。在这种情况下,您的AdView可以specify a custom size,与您在DFP广告管理系统中设置的尺寸相匹配。