當前位置: 首頁>>代碼示例>>Java>>正文


Java AdSize.BANNER屬性代碼示例

本文整理匯總了Java中com.google.android.gms.ads.AdSize.BANNER屬性的典型用法代碼示例。如果您正苦於以下問題:Java AdSize.BANNER屬性的具體用法?Java AdSize.BANNER怎麽用?Java AdSize.BANNER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.android.gms.ads.AdSize的用法示例。


在下文中一共展示了AdSize.BANNER屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAdSizeFromString

private AdSize getAdSizeFromString(String adSize) {
    switch (adSize) {
        case "banner":
            return AdSize.BANNER;
        case "largeBanner":
            return AdSize.LARGE_BANNER;
        case "mediumRectangle":
            return AdSize.MEDIUM_RECTANGLE;
        case "fullBanner":
            return AdSize.FULL_BANNER;
        case "leaderBoard":
            return AdSize.LEADERBOARD;
        case "smartBannerPortrait":
            return AdSize.SMART_BANNER;
        case "smartBannerLandscape":
            return AdSize.SMART_BANNER;
        case "smartBanner":
            return AdSize.SMART_BANNER;
        default:
            return AdSize.BANNER;
    }
}
 
開發者ID:sbugert,項目名稱:react-native-admob,代碼行數:22,代碼來源:RNPublisherBannerViewManager.java

示例2: parseAdSize

/**
 * Parses the ad size string obtained from Unity.
 * 
 * @param adSize
 * 
 * @return the parsed {@link AdSize}.
 */
private static AdSize parseAdSize(final String adSize) {
    if ("BANNER".equals(adSize)) {
        return AdSize.BANNER;
    } else if ("MEDIUM_RECTANGLE".equals(adSize)) {
        return AdSize.MEDIUM_RECTANGLE;
    } else if ("FULL_BANNER".equals(adSize)) {
        return AdSize.FULL_BANNER;
    } else if ("LEADERBOARD".equals(adSize)) {
        return AdSize.LEADERBOARD;
    } else if ("SMART_BANNER".equals(adSize)) {
        return AdSize.SMART_BANNER;
    }
    
    return null;
}
 
開發者ID:nabrozidhs,項目名稱:unity_admob_android,代碼行數:22,代碼來源:AdMob.java

示例3: adSizeFromString

/**
 * Gets an AdSize object from the string size passed in from JavaScript.
 * Returns null if an improper string is provided.
 *
 * @param size The string size representing an ad format constant.
 * @return An AdSize object used to create a banner.
 */
private static AdSize adSizeFromString(String size) {
    if ("BANNER".equals(size)) {
        return AdSize.BANNER;
    } else if ("FULL_BANNER".equals(size)) {
        return AdSize.FULL_BANNER;
    } else if ("LARGE_BANNER".equals(size)) {
        return AdSize.LARGE_BANNER;
    } else if ("LEADERBOARD".equals(size)) {
        return AdSize.LEADERBOARD;
    } else if ("MEDIUM_RECTANGLE".equals(size)) {
        return AdSize.MEDIUM_RECTANGLE;
    } else if ("WIDE_SKYSCRAPER".equals(size)) {
        return AdSize.WIDE_SKYSCRAPER;
    } else if ("SMART_BANNER".equals(size)) {
        return AdSize.SMART_BANNER;
    } else if ("FLUID".equals(size)) {
        return AdSize.FLUID;
    } else if ("SEARCH".equals(size)) {
        return AdSize.SEARCH;
    } else if ("IAB_BANNER".equals(size)) {
        return AdSize.FULL_BANNER;
    } else if ("IAB_MRECT".equals(size)) {
        return AdSize.MEDIUM_RECTANGLE;
    } else if ("IAB_LEADERBOARD".equals(size)) {
        return AdSize.LEADERBOARD;
    }
    return null;
}
 
開發者ID:ratson,項目名稱:cordova-plugin-admob-free,代碼行數:35,代碼來源:AdMobConfig.java

示例4: getAdSize

/**
 * Get the respective adSize according to the given index
 * 
 * @param idx adSize index to be searched
 * 
 * @return found adSize instance
 */
private AdSize getAdSize(int idx) {
   	mContext.log(CLASS+"getAdSize, idx: "+idx);
       // Return the AdSize according to the given index
	if(idx == 0)		return AdSize.BANNER;
       else if(idx == 1)	return AdSize.MEDIUM_RECTANGLE;
       else if(idx == 2)	return AdSize.FULL_BANNER;
       else if(idx == 3)	return AdSize.LEADERBOARD;
       else if(idx == 4)	return AdSize.WIDE_SKYSCRAPER;
       else if(idx == 5)	return AdSize.SMART_BANNER;
       else if(idx == 6)	return AdSize.SMART_BANNER;
       else if(idx == 7)	return AdSize.SMART_BANNER;
       // Return the default if not found
       return AdSize.BANNER;
}
 
開發者ID:mnashwan,項目名稱:AdMobAne,代碼行數:21,代碼來源:AdMobBanner.java

示例5: show

public void show(String adID, int size, /*int autoHW,*/ int halign, int valign, String testDevice)
{
	hide();
	
	switch(size)
	{
	case 1: _adSize = AdSize.BANNER; break; //set by default, but leave it here for reference
	case 2: _adSize = AdSize.MEDIUM_RECTANGLE; break;
	case 3: _adSize = AdSize.FULL_BANNER; break;
	case 4: _adSize = AdSize.LEADERBOARD; break;
	case 5: _adSize = AdSize.SMART_BANNER; break;
	case 6: _adSize = AdSize.WIDE_SKYSCRAPER; break;
	}
	
	_adView = new AdView(_act);
	_adView.setAdUnitId(adID);
	_adView.setAdSize(_adSize);
	
	AdRequest adRequest = null;
	if(testDevice == null) //no test device
		adRequest = new AdRequest.Builder().build();
	else
		adRequest = new AdRequest.Builder().addTestDevice(testDevice).build(); //eto pizdec
	
	_adView.setAdListener(new AdMobListener(_ctx, "BANNER"));
	
	_params = new RelativeLayout.LayoutParams(-2, -2);
	_params.addRule(halign, -1);
	_params.addRule(valign, -1);
	
	_parentView.addView(_adView, _params);

_adView.loadAd(adRequest);
}
 
開發者ID:pozirk,項目名稱:ANEAdMob,代碼行數:34,代碼來源:AdMobManager.java

示例6: createadmob

private RelativeLayout createadmob() {

        AdSize adSize = AdSize.SMART_BANNER;

        DisplayMetrics dm = getResources().getDisplayMetrics();

        double density = dm.density * 160;
        double x = Math.pow(dm.widthPixels / density, 2);
        double y = Math.pow(dm.heightPixels / density, 2);
        double screenInches = Math.sqrt(x + y);

        if (screenInches > 8) { // > 728 X 90
            adSize = AdSize.LEADERBOARD;
        } else if (screenInches > 6) { // > 468 X 60
            adSize = AdSize.MEDIUM_RECTANGLE;
        } else { // > 320 X 50
            adSize = AdSize.BANNER;
        }

        adSize = AdSize.MEDIUM_RECTANGLE;
        final AdView mAdView = new AdView(this);
        mAdView.setAdSize(adSize);
        mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
        // Create an ad request.
        AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
        if (admob_test_mode)
            // Optionally populate the ad request builder.
            adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        // Start loading the ad.
        mAdView.loadAd(adRequestBuilder.build());
        DisplayMetrics displaymetrics = new DisplayMetrics();
        final RelativeLayout layout = AdGoogleDisplaySupport.initialSupport(this, displaymetrics);
        final double ratio = AdGoogleDisplaySupport.ratioMatching(displaymetrics);
        final int ad_height = AdGoogleDisplaySupport.defaultHeight(displaymetrics);
        AdGoogleDisplaySupport.panelAdjust(mAdView, (int) (ad_height * ratio));
        // get display info
        /*  G.display_w = displayMetrics.widthPixels;
        G.display_h = displayMetrics.heightPixels;
        G.scale = Math.max(G.display_w/1280.0f, G.display_h/800.0f);*/
        mAdView.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                int h = mAdView.getLayoutParams().height;
                AdGoogleDisplaySupport.scale(mAdView, ratio);
                AdGoogleDisplaySupport.panelAdjust(mAdView, (int) (h * ratio));
                //  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            }
        });
        layout.addView(mAdView);
        return layout;
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:52,代碼來源:TestAdvancedAdmobActivity.java


注:本文中的com.google.android.gms.ads.AdSize.BANNER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。