http://i.stack.imgur.com/lbs7l.png
我正在尝试在背景下设置 admob,但我总是像这样在背景之上设置 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 的服务条款。
关于android - Admob 低于背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9476936/