Android admob横幅广告与主版面重叠
我的android应用程序中的Admob横幅广告与主布局的底部重叠,这里有许多解决方案,但没有一个对我有效。我如何区分这两个布局。下面是我的activity.main.xmlAndroid admob横幅广告与主版面重叠,android,android-layout,admob,Android,Android Layout,Admob,我的android应用程序中的Admob横幅广告与主布局的底部重叠,这里有许多解决方案,但没有一个对我有效。我如何区分这两个布局。下面是我的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.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>
问题在于: Admob广告在顶部对齐,底部对齐,因此它与您的网络视图重叠,从而获得屏幕的全宽和全高 有两种方法可以避免WebView上的广告重叠 解决方案1: 将页边距从底部添加到Webview
android:layout_marginBottom="50dp" or android:layout_marginBottom="90dp"
使用“智能横幅”时,您可以在两个不同的“维度.xml”wrt屏幕分辨率和大小中配置硬代码值,即“50dp”和“90dp”
解决方案2:
您可以使用LinearLayout同时包含“WebView”和“Admob Ad”,并仅为WebView分配权重,如下代码所示
<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>
选择是你自己的,你跟随
注意:不要在布局中使用填充父项,因为它们已被弃用为adview提供一些硬代码高度。。再次检查代码我将更新代码我也需要帮助,我将横幅放在屏幕顶部,但当抽屉导航视图打开时,将横幅半水平覆盖。今天我收到一封关于尽快解决这个问题的邮件,但我真的不知道这个或任何其他本地或横幅的内容重叠的原因。请纠正我这里抽屉会不会造成重叠广告的问题???需要帮助吗
<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>