遵循此代码(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 代码的大小。(inonCreate()
或onReceiveAd()
) 用于调整广告的大小。
LayoutParam,以 CenterCrop 为例,或者简单地调整视图大小!