簡體   English   中英

智能橫幅加載到全屏尺寸

[英]Smart banner loading to full screen size

智能橫幅加載適應全屏尺寸的廣告正在加載,如下圖所示 在此處輸入圖片說明

如何解決這個問題呢

在智能橫幅中加載視頻時,就會出現此問題

我用於最新的fcm廣告依賴項'com.google.firebase:firebase-ads:18.1.0'

此錯誤來自android 9.0設備

我的代碼如下

 public static LinearLayout add;
        public static AdView adView;
        public static AdRequest request;

    public void load_add(final LinearLayout addViw) {
            adView = new AdView(Main_open.this);
            adView.setAdSize(AdSize.SMART_BANNER);
            adView.setAdUnitId(BANNAER_ID);
            request = new AdRequest.Builder().build();

            sharedPreference.putInt(getApplicationContext(), "addloded", 0);
            adView.setAdListener(new AdListener() {
                public void onAdLoaded() {
                    sharedPreference.putInt(getApplicationContext(), "addloded", 1);
                    Main_open.load_addFromMain(Main_open.this, add);

                    super.onAdLoaded();
                }

                public void onAdFailedToLoad(int errorcode) {
                    /*load_add(addViw);*/
                }
            });

            adView.loadAd(request);
            if (adView != null) {
                ViewGroup parentViewGroup = (ViewGroup) adView.getParent();
                if (parentViewGroup != null) {
                    parentViewGroup.removeAllViews();
                }
            }
        }

        public static void load_addFromMain(Context context, LinearLayout add_banner) {
            add = add_banner;
            try {
                if (adView != null) {
                    ViewGroup parentViewGroup = (ViewGroup) adView.getParent();
                    if (parentViewGroup != null) {
                        parentViewGroup.removeAllViews();
                    }
                }
                if (sharedPreference.getInt(context, "addloded") == 1) {
                    add_banner.setVisibility(View.VISIBLE);
                    add_banner.removeAllViews();
                    add_banner.addView(adView);
                }

            } catch (Exception e) {
                System.out.println("Ad Exception " + e);
            }

        }
    LinearLayout ads_lay = findViewById(R.id.ads_lay);
    load_addFromMain(CashList_Fragment.this, ads_lay);

我不確定,但是將此代碼放在應用標簽下的清單文件中

 <uses-library
        android:name="org.apache.http.legacy"
        android:required="false" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM