2017-07-26 23 views
0

私のアンドロイドミュージックプレーヤーのポップアッププレイヤーにバナーを追加します。 Androidのスタジオプレビューモードでは、エラーはなく、正常に動作しますが、バナーが表示されません。ポップアップにadmobのバナーが表示されない

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 

xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:layout_width="320dp" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:weightSum="1.0"> 


<RelativeLayout  
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/primary" 
    android:paddingBottom="5dp" 
    android:paddingLeft="20dp" 
    android:paddingRight="20dp" 
    android:paddingTop="20dp"> 

    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:maxLines="5" 
     android:textColor="@color/white" 
     android:textSize="@dimen/text_medium" 
     tools:text="Mr.Afghani" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/name" 
     android:gravity="center_vertical"> 

     <ImageView 
      android:id="@+id/play" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="6" 
      android:src="@mipmap/play" /> 

     <ImageView 
      android:id="@+id/pause" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="6" 
      android:src="@mipmap/pause" 
      android:visibility="gone" /> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.8" 
      android:paddingEnd="10dp" 
      android:paddingRight="10dp"> 

      <SeekBar 
       android:id="@+id/media_seekbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" /> 

      <TextView 
       android:id="@+id/playback_time" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="end|top" 
       android:ellipsize="end" 
       android:textColor="@color/white" 
       android:textSize="11sp" 
       tools:text="00:00" /> 
     </FrameLayout> 
    </LinearLayout> 

</RelativeLayout> 

<com.google.android.gms.ads.AdView 
    android:id="@id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/bannerAd1" /> 
</LinearLayout> 

mainActivityで私のコードは正しいと思います。私は他の画面にバナーを入れてみましたが、うまくいきました。ポップアップ画面にバナーを入れる方法はありますか?

MainActivityでの私のコードは次のとおりです。

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    init(); 
    AdView mAdView = (AdView) findViewById(R.id.adView); 
    AdRequest request = new AdRequest.Builder().build(); 
    mAdView.loadAd(request); 



    mInterstitialAd = new InterstitialAd(this); 
    mInterstitialAd.setAdUnitId("ca-app-pub-1234"); 
    AdRequest adRequest = new AdRequest.Builder().build(); 
    mInterstitialAd.loadAd(adRequest); 
    mInterstitialAd.setAdListener(new AdListener() { 
     @Override 
     public void onAdClosed() { 
      AdRequest adRequest1 = new AdRequest.Builder().build(); 
      mInterstitialAd.loadAd(adRequest1); 
     } 
    }); 

答えて

1

ダイアログ/ポップアップで表示されない広告の主な理由は、表示する十分なスペース(幅)を得ていないバナー広告によるものです。 は、広告サイズを覚えている:あなたはBanner広告サイズを使用しているので、

ので
320x50  Standard Banner  Phones and Tablets BANNER 
320x100  Large Banner   Phones and Tablets LARGE_BANNER 
300x250  IAB Medium Rectangle Phones and Tablets MEDIUM_RECTANGLE 
468x60  IAB Full-Size Banner Tablets    FULL_BANNER 
728x90  IAB Leaderboard  Tablets    LEADERBOARD 
Screen  width x 32|50|90  Smart Banner  Phones and Tablets SMART_BANNER 

Source

、あなたがポップアップ表示中の広告を有効にするには、320の少なくとも幅の大きさを持っていることを確認してください。十分なスペースがあり、広告がまだ表示されない場合、問題は有効率の問題になる可能性があります。つまり、お客様の地域に広告を掲載することはできません。 onCreate()方法で

、あなたは、デバイスの画面の幅全体をカバーするために、ダイアログの幅を設定することができます:私は、これは

UPDATEを助けている場合教えてください

DisplayMetrics metrics = getResources().getDisplayMetrics(); 
     // int screenWidth = (int) (metrics.widthPixels * 0.99); //99 percent 
     boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; 
     if(isLandscape) 
      getWindow().setLayout((int) (metrics.widthPixels * 0.70), ViewGroup.LayoutParams.WRAP_CONTENT); 
     else getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 

いつでも確認することができます問題がバナーサイズであるかどうかを確認するためにアンドロイドスタジオにログインします

+0

ありがとうナナ、でも同じ問題です。あなたが言ったように投稿された質問を編集しました。どうぞご覧ください。 –

+0

https://ibb.co/dMoraQ ...ここにスクリーンショットがあります。 –

+0

@myads mailあなたがしたことは、ダイアログ自体に影響を与えないレイアウトの幅に設定されています。幅にmatch_parentを使用し、横向きモードでテストして動作するか確認してください。 –

関連する問題