2012-02-02 1 views
0

Я разработал приложение для Android. Мое приложение будет использоваться в ландшафтном режиме. Теперь я хочу разместить объявление с левой стороны по вертикали. Является ли это возможным? если нет, пожалуйста, как разместить его по горизонтали вверху?Как добавить admob в relativelayout

Моя раскладка

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:orientation="horizontal" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageView android:id="@+id/s1" android:layout_width="wrap_content" 
     android:src="@drawable/a_1" android:layout_height="wrap_content" 
     android:padding="2dp" /> 

    <ImageView android:id="@+id/s2" android:layout_width="wrap_content" 
     android:src="@drawable/a_2" android:layout_height="wrap_content" 
     android:padding="2dp" /> 

    <ImageView android:id="@+id/s3" android:layout_width="wrap_content" 
     android:src="@drawable/a_3" android:layout_height="wrap_content" 
     android:padding="2dp" /> 

    <ImageView android:id="@+id/s4" android:layout_width="wrap_content" 
     android:src="@drawable/a_4" android:layout_height="wrap_content" 
     android:padding="2dp" /> 

    <RelativeLayout android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:layout_alignParentBottom="true" 
     android:gravity="center" android:background="#00000000"> 

    <TextView android:id="@+id/l" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:paddingLeft="20dp" 
     android:paddingRight="20dp" android:background="@drawable/letterbackground" 
     android:textColor="#FFFFFFFF" android:textSize="60sp" 
     android:shadowColor="#AA42d68b" android:shadowRadius="1.5" 
     android:shadowDx="5" android:shadowDy="5" android:text="A" /> 
    </RelativeLayout> 

    <RelativeLayout android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

    <TextView android:layout_width="fill_parent" 
     android:layout_height="wrap_content"    
     android:id="@+id/menu_widget" /> 
    </RelativeLayout> 
</RelativeLayout> 

ответ

0

Вы должны поместить AdMob AdView в коде (в вашей деятельности или фрагмента). Объявление появится, когда вы получите фактическое объявление (горизонтально вверху).

Вот пример, который должен работать:

<?xml version="1.0" encoding="utf-8"?> 


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:orientation="horizontal" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <LinearLayout 
     xmlns:myapp="http://schemas.android.com/apk/res/your.app.package" 
     android:id="@+id/ad_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 
    </LinearLayout> 

    <Put the rest of the layout here> 
    </Put the rest of the layout here> 
</RelativeLayout> 
0

По Admob версии 6.4.1, вы не должны даже для конкретизации деятельности, вы можете добавить объявление как вид непосредственно:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:orientation="horizontal" android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<com.google.ads.AdView android:id="@+id/ad" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:layout_alignParentBottom="true" 
         ads:adSize="BANNER" 
         ads:adUnitId="a151b78112c1df4" 
         ads:testDevices="TEST_EMULATOR,TEST_DEVICE_ID_GOES_HERE" 
         ads:loadAdOnCreate="true"/> 
</RelativeLayout>