开发者

Android webview with admob ad on the bottom

I've been busting my head on this all day and haven't been able to figure it out. I have a webview and would like an admob ad on the bottom. What should my x开发者_如何学Cml look like? should i configure admob in xml or using code? thanks


You can have a vertical linear layout with your webview and admob view in xml file. Then setting android:layout_weight="1" for webview ,will push your admob view to the bottom of your layout


<?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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜