Когда я помещаю код баннера в mainactivity.xml, меню отрицания не работает?
Когда я помещаю код рекламных баннеров admob в Mainactivity.xml, тогда меню отрицания не работает, а также покрывает фоновый контент? Тестирование рекламных баннеров работает, но меню отрицания не работает .... Как я могу исправить эту проблему.
Вот мой код 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>
1 ответ
Решение
На самом деле это нарушает правила AdMob, реклама перекрывается с контентом приложения (противоречит правилам).
Итак, правильный способ сделать это - разместить баннер в другом месте.