我一整天都在琢磨这个问题,但还是无法解决。我有一个网页视图并希望在底部放置AdMob广告。我的XML应该是什么样子的?我应该在XML或代码中配置AdMob吗?谢谢。
我一整天都在琢磨这个问题,但还是无法解决。我有一个网页视图并希望在底部放置AdMob广告。我的XML应该是什么样子的?我应该在XML或代码中配置AdMob吗?谢谢。
您可以在xml文件中使用垂直线性布局(vertical linear layout)来安排您的Webview和Admob视图。然后为Webview设置android:layout_weight="1"
,这将把您的Admob视图推到布局底部。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent" android:id="@+id/rltvLayout1"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/linearLayoutwebview"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical">
<WebView android:id="@+id/webView1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fitsSystemWindows="true" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/ad_layout" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_alignParentBottom="true"
android:layout_alignBottom="@+id/home_layout">
<com.google.ads.AdView android:layout_width="wrap_content"
android:layout_height="wrap_content" ads:adUnitId="put here Your Id "
ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" />
</LinearLayout>
</RelativeLayout>