http://i.stack.imgur.com/lbs7l.png
Я пытаюсь настроить admob ниже фона, но я продолжаю получать поддержку на фоне такого фона. http://i.stack.imgur.com/YJXU2.png
Итак, что случилось, у меня есть кнопка alignedParentBottom = "true", но объявление продолжает закрывать кнопку.
<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>
Вы можете создать второй RelativeLayout - у внутреннего будет весь основной контент макета, а внешний будет содержать ваш макет и AdView. Просто установите AdView в нижнюю часть и настройте контент RelativeLayout над AdView, и он заставит кнопку "Назад" вернуться, когда объявление вернется.
Здесь я предоставил код для вашего удобства.
<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" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_above="@+id/adView2">
<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>
</RelativeLayout>
<com.google.ads.AdView android:id="@id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adUnitId="MY_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true">
</com.google.ads.AdView>
</RelativeLayout>
Примечание: убедитесь, что элементы пользовательского интерфейса не слишком близки к объявлениям; которые могут поощрять случайные клики и против AdMob ToS.
Используйте FrameLayout:
Представления для детей рисуются в стеке, причем последний добавленный ребенок сверху.
Там ничего не поделаешь. Если вы хотите, чтобы кнопка была нарисована над AdView, поместите AdView ранее в общий родитель FrameLayout. Например,
<FrameLayout 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">
<com.google.ads.AdView android:id="@+id/adView2" ... />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
... Buttons, etc. ...
</RelativeLayout>
</FrameLayout>
Хотя вам может понадобиться только Button и AdView в дочернем элементе FrameLayout RelativeLayout. Или вы можете захотеть родитель RelativeLayout для AdView в приведенном выше примере, чтобы разместить объявление.