[英]how to place admob ad in seperate container at bottom of app?
I have added admob to my app and placed the ad at the bottom of the page.... hoever it covers the web content that i need people to see.... is there anyway to place the ad in a separate container or frame at the bottom of the screen so that the content stops where the ad begins? 我已将admob添加到我的应用中,并将该广告放置在页面底部。...不过它覆盖了我需要人们看到的Web内容。...无论如何,都可以将广告放置在单独的容器或框架中在屏幕底部,以便内容在广告开始的地方停止?
here is my xml file 这是我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:tools="http://schemas.android.com/tools"
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.payforlikes.app.payforlikes.MainActivity"
tools:showIn="@layout/activity_main">
<WebView
android:id="@+id/activity_main_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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="ca-app-pub-4075500144464557/1187222817"/>
</RelativeLayout>
You should be able to rearrange your XML as follows: 您应该能够按照以下方式重新排列XML:
<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="ID"/>
<WebView
android:id="@+id/activity_main_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/adView />
You move the WebView
below the AdView
in your XML so you can reference the AdView
's ID, and then, using your RelativeLayout
, you can restrict the WebView
to be above the AdView
. 您可以将XML中的WebView
移到AdView
下方,以便可以引用AdView
的ID,然后使用RelativeLayout
将WebView
限制在AdView
上方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.