2016-08-07 11 views
1

私のアンドロイドアプリのAdmobバナー広告はメインレイアウトの下部に重なっていますが、ここには多くの解決策がありますが、それらのものは私のために働いていません。あるBOTTOM WRT親、従ってその重なり合うあなたのWebView |admobバナー広告がメインレイアウトと重複する

AdMobの広告がTOPに揃えている:私のactivity.main.xmlされ、次の

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawerLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:ads="http://schemas.android.com/apk/res-auto"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/coordinator_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <ProgressBar 
      android:id="@+id/progressBar1" 
      style="?android:attr/progressBarStyleLarge" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_centerHorizontal="true" 
      android:indeterminate="false" 
      android:layout_gravity="center" /> 

     <WebView 
      android:id="@+id/webView1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"/> 

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_gravity="bottom" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentBottom="true" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="@string/banner_ad_unit_id"> 
     </com.google.android.gms.ads.AdView> 

    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:itemIconTint="#d20b0d" 
     app:itemTextColor="#333" 
     app:menu="@menu/navigation_items" /> 
</android.support.v4.widget.DrawerLayout> 

答えて

0
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/drawerLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/coordinator_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ProgressBar 
     android:id="@+id/progressBar1" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_centerHorizontal="true" 
     android:layout_gravity="center" 
     android:indeterminate="false" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <WebView 
      android:id="@+id/webView1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="match_parent" 
      android:layout_height="120dp" 
      android:layout_gravity="bottom" 
      ads:adSize="SMART_BANNER" 

      ads:adUnitId="@string/banner_ad_unit_id"></com.google.android.gms.ads.AdView> 
    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    app:itemIconTint="#d20b0d" 
    app:itemTextColor="#333" 
    app:menu="@menu/navigation_items" /> 

+0

@Dnyneshは広告が表示されない非推奨されているとして、あなたのレイアウトでfill_parentを使用しないでください。 –

+0

adviewへのハードコードの高さを教えてください。もう一度コードをチェックしてください。コードを更新します。 – Dnyanesh

0

問題はということです画面の全幅と高さを取得します。

あなたはWebViewの

ソリューション1広告の重複を避けるために従うことができる2つの方法があります:あなたはSMART "を使用していると

android:layout_marginBottom="50dp" or android:layout_marginBottom="90dp" 

をWebViewのためにmargin_bottomを与える

は、 BANNER "の2種類の異なる" dimens.xml "にハードコード値、つまり" 50dp "と" 90dp " WRTの画面の解像度とサイズ

ソリューション2

あなたは「のWebView」と「AdMobの広告」の両方を含み、コードの下のように、唯一のWebViewに重みを割り当てるためのLinearLayoutを使用することができます。

<android.support.v4.widget.DrawerLayout 
    android:id="@+id/drawerLayout" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/coordinator_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <ProgressBar 
      android:id="@+id/progressBar1" 
      style="?android:attr/progressBarStyleLarge" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_gravity="center" 
      android:indeterminate="false"/> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <WebView 
       android:id="@+id/webView1" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"/> 

      <com.google.android.gms.ads.AdView 
       android:id="@+id/adView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       ads:adSize="SMART_BANNER" 
       ads:adUnitId="@string/banner_ad_unit_id"> 
      </com.google.android.gms.ads.AdView> 

     </LinearLayout> 

    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:itemIconTint="#d20b0d" 
     app:itemTextColor="#333" 
     app:menu="@menu/navigation_items"/> 
</android.support.v4.widget.DrawerLayout> 

あなたが選択したのはあなたです。

は注意:彼らはこのレイアウトとして機能していない

関連する問題