您可以在底部放置广告,而不是在顶部放置横幅广告

时间:2014-01-28 15:28:49

标签: android xml

我想知道是否可以将我的广告放在屏幕底部的顶部我认为应用程序我有这个xml Ben这是新的,现在我得到错误请帮助我,我知道在哪里放置所有按钮和textview

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="fill"
    tools:context=".MainActivity"
    tools:ignore="contentDescription" >

        <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"

        android:layout_above="@id/ad"
        />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="0"
        android:textSize="40sp"
        tools:ignore="HardcodedText" />

    <Button
        android:id="@+id/button1"
        style="@drawable/cherries" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="14dp"
        android:background="@drawable/cherries"
        android:gravity="center"
        android:minHeight="200dp"
        android:minWidth="200dp" />

     <com.google.ads.AdView
         android:id="@+id/ad"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         ads:adSize="BANNER"
         ads:adUnitId="ca-app-pub-9703280417137355/6644841052"
         ads:loadAdOnCreate="true"
         ads:testDevices="TEST_EMULATOR" >
     </com.google.ads.AdView>

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

您希望将其粘贴在RelativeLayout中并将其与父母的底部对齐。

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

    <com.mopub.mobileads.MoPubView
        android:id="@+id/adview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        android:layout_alignParentBottom="true"
    />


    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"

        android:layout_above="@id/adview"
        >

        .. put content here

    </LinearLayout>

</RelativeLayout>