【问题标题】:When i put banner code in mainactivity.xml then negivation menu is not working?当我将横幅代码放入 mainactivity.xml 时,negivation 菜单不起作用?
【发布时间】:2021-09-07 11:56:46
【问题描述】:

当我将 admob 横幅广告代码放入 Mainactivity.xml 时,negivation 菜单不起作用并且还覆盖了背景内容? 测试横幅广告正在工作,但 negivation 菜单不起作用.... 我该如何解决这个问题。

这是我的 Mainactivity.xml 代码

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="com.governmentjobonline.MainActivity">

   <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar_layout" />
            <include layout="@layout/tab_layout" />
    </LinearLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/drawer_header"
        app:itemTextAppearance="?android:attr/textAppearanceMedium"
        app:menu="@menu/navigation_drawer">
    </com.google.android.material.navigation.NavigationView>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <!-- set Banner ad position in UI layout design -->
        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            ads:adSize="FULL_BANNER"
            ads:adUnitId="@string/admob_banner_id">
        </com.google.android.gms.ads.AdView>
  </RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>

【问题讨论】:

    标签: android admob banner android-banner


    【解决方案1】:

    这实际上违反了 AdMob 准则,Ad overlapping with app content (against policy)

    因此,正确的做法是将横幅广告放在别处。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 1970-01-01
      • 1970-01-01
      • 2021-12-19
      相关资源
      最近更新 更多