【发布时间】:2011-06-30 01:20:53
【问题描述】:
我整天都在琢磨这个问题,但一直没弄明白。我有一个 webview,想在底部放一个 admob 广告。我的 xml 应该是什么样的?我应该在 xml 中配置 admob 还是使用代码?谢谢
【问题讨论】:
标签: android xml android-layout webview admob
我整天都在琢磨这个问题,但一直没弄明白。我有一个 webview,想在底部放一个 admob 广告。我的 xml 应该是什么样的?我应该在 xml 中配置 admob 还是使用代码?谢谢
【问题讨论】:
标签: android xml android-layout webview admob
您可以在 xml 文件中使用 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>
【讨论】: