2017-02-19 15 views
1

最近私のAndroidアプリでadmobのバナー広告を使用し始めました。それはうまくいっていますが、いくつか問題があります。今のところ、SMART_BANNERではなく、BANNERを使用しています。私のバナーは、小さなグループを除いてほとんどの携帯電話で動作します。私のエミュレータでは、バナーが画面に対して大きすぎるときに問題が発生することがわかります。android studioの画面サイズにadmob bannerのサイズを変更する

スマートバナーを使ってみましたが、logcatで同じメッセージが表示されました。「バナーは340x50しか必要ではなく、288x460しか持っていません。私のバナーはほとんどの5インチのスクリーンでしか使えませんが、小さなスクリーンサイズでアプリを試してみると、バナーは見えません。

私のバナーは全画面に合わせてサイズを変更しますサイズ

ここで私は広告バナー作成するために使用する私のコードです:?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" android:layout_height="match_parent"> 

    <android.support.percent.PercentRelativeLayout 

     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:id="@+id/timer1background2" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="127dp" 
      android:id="@+id/TimerTextview1" 
      android:textColor="@android:color/black" 
      android:textStyle="normal|bold" 
      app:layout_marginTopPercent="11%" 
      android:text="APP NAME" 
      android:textSize="45dp" /> 

     <Button 
      android:text="Go To Timer 1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:id="@+id/StartB1" 
      android:textColor="@android:color/background_light" 
      android:background="@color/colorPrimaryDark" 
      android:textStyle="normal|bold" 
      android:textSize="35sp" 
      app:layout_marginTopPercent="33%" 
      app:layout_heightPercent="15%"/> 

     <Button 
      android:text="Go To Timer 2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:id="@+id/StartB2" 
      android:textColor="@android:color/background_light" 
      android:background="@color/colorPrimaryDark" 
      android:textStyle="normal|bold" 
      android:textSize="35sp" 
      app:layout_marginTopPercent="58%" 
      app:layout_heightPercent="15%"/> 

    </android.support.percent.PercentRelativeLayout> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="MY KEY"> 
    </com.google.android.gms.ads.AdView> 
</RelativeLayout> 

そして:広告、バナー広告のGoogleドキュメントから

//Load ads 
MobileAds.initialize(getActivity().getApplicationContext(), "MY KEY"); 

AdView adView = (AdView) myView.findViewById(R.id.adView); 
AdRequest adRequest = new AdRequest.Builder().build(); 
adView.loadAd(adRequest); 

答えて

0

は、特定のサイズがあります、フルスクリーン広告の場合は、インタースティシャル広告を使用する必要があります。 Documented here

+0

で画面の幅を埋めるスマートバナーですバナーは320x50です。では、画面のサイズがそれより小さい場合はどうなりますか? – AndreasWT

+0

それは比率です。デバイスの幅が変化する場合は、広告ビューで調整されます。 – ADM

+0

あなたが言うように私がするとき、広告は表示されません。画面に余裕があるときのみ。 – AndreasWT

0

定期的なバナーが固定サイズで来て、あなたはあなたが必要なもの、彼らに

を拡張カントはあなたがその最小幅x高を見ることができます

ルックthis

関連する問題