本文整理匯總了Java中com.google.android.gms.ads.AdView.setId方法的典型用法代碼示例。如果您正苦於以下問題:Java AdView.setId方法的具體用法?Java AdView.setId怎麽用?Java AdView.setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.ads.AdView
的用法示例。
在下文中一共展示了AdView.setId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAdView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private AdView createAdView() {
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.LARGE_BANNER);
// setup "testing" banner type
boolean isStoreBuild = BuildConfig.FLAVOR.equals("playstore") && BuildConfig.BUILD_TYPE.equals("release");
String adUnitId = isStoreBuild ? AD_UNIT_ID : "ca-app-pub-3940256099942544/6300978111";
mAdView.setAdUnitId(adUnitId);
mAdView.setId(View.generateViewId()); // this is an arbitrary id, allows for relative positioning in createGameView()
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
mAdView.setLayoutParams(params);
mAdView.setBackgroundColor(Color.BLACK);
return mAdView;
}
示例2: createAdView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private void createAdView() {
adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(AD_UNIT_ID);
adView.setId(R.id.adsMobId); // this is an arbitrary id, allows for relative positioning in createGameView()
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
adView.setLayoutParams(params);
adView.setBackgroundColor(Color.BLACK);
}
示例3: createAdView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private AdView createAdView() {
adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(AD_UNIT_ID);
adView.setId(12345); // this is an arbitrary id, allows for relative positioning in createGameView()
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
adView.setLayoutParams(params);
adView.setBackgroundColor(Color.BLACK);
return adView;
}
示例4: createAdView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private AdView createAdView() {
AdView adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(getString(R.string.ad_banner1));
adView.setId(12345);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
adView.setLayoutParams(params);
adView.setBackgroundColor(Color.BLACK);
return adView;
}
示例5: createAdView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private AdView createAdView() {
adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(SMALL_CODE);
adView.setId(12345); // this is an arbitrary id, allows for relative positioning in createGameView()
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
layout.setLayoutParams(params);
adView.setLayoutParams(params);
adView.setBackgroundColor(Color.TRANSPARENT);
return adView;
}