how to add ads to android app without overlapping with my content

杀马特。学长 韩版系。学妹 提交于 2019-12-06 06:18:59

You can use structure as given below. Align adView to android:layout_alignParentBottom="true" and align your LinearLayout above this adView by setting LinearLayout's attribute to android:layout_above="@id/adView".

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidsam="http://schemas.android.com/apk/res/com.jameselsey"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR" />

    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/adView"
        android:background="@drawable/background"
        android:orientation="vertical" >

        <!-- Your layout components should be here-->

    </LinearLayout>

</RelativeLayout>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!