Reputation: 6522
I've seen a lot of apps have ads at the edge of the screen. But when I'm trying to put ads at the absolute edge of the layout, it automatically places it a few dp apart from the edge.
This is the XML:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, MY_DEVICE_ID"
app:adSize="BANNER"
app:adUnitId="MY_DEV_CODE" >
</com.google.ads.AdView>
Full XML code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tBtn1"
android:layout_alignBottom="@+id/tBtn1"
android:layout_toRightOf="@+id/tBtn1"
android:text="Record as long as the button is touched" />
<ToggleButton
android:id="@+id/tBtn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOff="Off"
android:textOn="On" />
<Chronometer
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/recButton"
android:layout_centerHorizontal="true"
android:text="Chronometer"
android:layout_marginTop="10dp" />
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, MY_DEVICE_ID"
app:adSize="BANNER"
app:adUnitId="MY_DEV_ID" >
</com.google.ads.AdView>
<ImageButton
android:id="@+id/recButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@null"
android:src="@drawable/record_btn" />
Upvotes: 1
Views: 178
Reputation: 851
And that's the matter:
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
Don't use a padding of the Parent-view for the padding bottom and it will work.
Upvotes: 1