как добавить рекламу в приложение для Android, не перекрывая мой контент - PullRequest
2 голосов
/ 05 февраля 2012

Я добавляю рекламу в свое приложение (это мой первый раз), но оно всегда пересекается с моим контентом (т.е. он отображается поверх моего контента).

Мой xml:

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:androidsam="http://schemas.android.com/apk/res/com.jameselsey"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">


<LinearLayout android:layout_width="fill_parent"
                  android:id="@+id/home_layout"
                  android:orientation="vertical"
                  android:layout_height="wrap_content"
                  android:background="@drawable/background">

     <TextView
        android:id="@+id/my_text"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        android:text="TextView2"
        android:textColor="#ffffff" 
        android:textColorHighlight="#000000"
        android:shadowColor="#000000"
        android:shadowDx="3"
        android:shadowDy="-3"
        android:shadowRadius="1.5"
        android:fadingEdge="horizontal"
        android:typeface="serif"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        />

</LinearLayout>   





<LinearLayout 
                  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
                  android:layout_width="fill_parent"
                  android:id="@+id/ad_layout"
                  android:layout_height="wrap_content"
                  android:layout_alignParentBottom="true"
                >
<com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="a14f26e5d930307"
                         ads:adSize="BANNER"
                         ads:testDevices="TEST_EMULATOR, 33334750709D00EC"
                         ads:loadAdOnCreate="true"/>
    </LinearLayout>


</RelativeLayout>

Объявление показывается внизу экрана, но оно скрывает конец TextView!Любые идеи, чтобы сделать это без наложения с TextView?

Заранее спасибо:)

1 Ответ

4 голосов
/ 05 февраля 2012

Вы можете использовать структуру, как указано ниже. Выровняйте adView по android:layout_alignParentBottom="true" и выровняйте свой LinearLayout над этим adView, установив атрибут LinearLayout в android:layout_above="@id/adView".

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

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR" />

    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/adView"
        android:background="@drawable/background"
        android:orientation="vertical" >

        <!-- Your layout components should be here-->

    </LinearLayout>

</RelativeLayout>
...