Плавающий рекламный баннер внизу экрана

У меня есть следующий дизайн xml -

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:background="@drawable/wall"
    android:orientation="vertical"
    tools:context="com.ahl.XXXXX.MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.5"
            android:background="@color/XXXXX"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX" 
            android:textColor="@color/White"/>

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.5"
            android:background="@color/XXXXX"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX" 
            android:textColor="@color/White"/>

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="@color/XXXXX"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX"
            android:textColor="@color/White"/>

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/Gray"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX"
            android:textColor="@color/White"/>
    </LinearLayout>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adViewB1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-6805003743867442/4243673212" >

    </com.google.android.gms.ads.AdView>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <WebView
            android:id="@+id/WebView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </ScrollView>

</LinearLayout>

Я хочу разместить рекламный баннер внизу экрана. Я пытался использовать относительный макет, но он не работает с веб-просмотром. Я видел другие подобные вопросы, но здесь веб-просмотр вызывает некоторые проблемы, поскольку он покрывает весь экран... поэтому мне пришлось использовать linearlayout.

Должен ли я размещать рекламу над веб-просмотром ИЛИ над родительским Linearlayout ??

Какие изменения я могу внести в приведенный выше XML, чтобы объявление отображалось внизу экрана.


person user2952821    schedule 01.01.2015    source источник
comment
почему ваш веб-просмотр покрывает весь экран, когда вы используете относительную компоновку? Вы можете установить его высоту.   -  person sam    schedule 01.01.2015


Ответы (1)


Я подозреваю, что вы имеете в виду, что вы хотите, чтобы AdView отображался внизу экрана. Вы действительно не хотите перемещать AdView поверх чего-либо.

Настройте свой WebView на расширение, чтобы заполнить неиспользуемое пространство, используя layout_weight="1", и отобразите AdView под ним. Например.

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
>

    <WebView
        android:id="@+id/WebView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</ScrollView>

<com.google.android.gms.ads.AdView
    android:id="@+id/adViewB1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-6805003743867442/4243673212" >

</com.google.android.gms.ads.AdView>
person William    schedule 01.01.2015