https://i.stack.imgur.com/lbs7l.png
I’m trying to setup admob below the background, but I keep getting admob on top of the background like this .
https://i.stack.imgur.com/YJXU2.png
So what happened is I have a button alignedParentBottom=”true”
but the ad is keep covering the button.
<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:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/backButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/back"
android:textSize="40sp"
android:layout_alignParentBottom="true"
></Button>
<ScrollView
android:id="@+id/ScrollView1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/backButton"
>
<TextView
android:id="@+id/TextView1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="20sp"
android:text="@string/helphelp"></TextView>
</ScrollView>
<com.google.ads.AdView android:id="@+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"
android:layout_below="@id/backButton"></com.google.ads.AdView>
You can create a second RelativeLayout – the inner one will have all of your main layout content, and the outer one will hold your layout content and the AdView. Simply set the AdView to the bottom, and set your RelativeLayout content above the AdView, and it will force the back button up when the ad comes back.
I have provided the code here for your convenience.
Side note: Make sure your UI elements aren’t too close to the ads; that may encourage accidental clicks, and is against AdMob’s ToS.