ScrollView переместил объявления AdMob - PullRequest
2 голосов
/ 02 июня 2011

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

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/pattern_carbon_fiber_dark">

<ScrollView android:id="@+id/ScrollView01"
android:layout_width="wrap_content" android:layout_height="339px">

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

<TextView android:text="Silent Mode" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/silent_textview"></TextView>
<ToggleButton android:layout_height="wrap_content" android:text="Silent Mode" android:id="@+id/silentbutton" android:layout_width="wrap_content" android:textOff="OFF" android:textOn="ON"></ToggleButton>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Wifi " android:id="@+id/wifi_textview"></TextView>
<ToggleButton android:layout_width="wrap_content" android:text="ToggleButton" android:layout_height="wrap_content" android:id="@+id/wifibutton"></ToggleButton>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/gps" android:id="@+id/gps_textview"></TextView>
<Button android:text="@string/gpsbutton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/gps"></Button>
<TextView android:layout_width="wrap_content" android:text="@string/bluetooth" android:layout_height="wrap_content" android:id="@+id/bluetooth_textview"></TextView>
<ToggleButton android:layout_width="wrap_content" android:text="ToggleButton" android:id="@+id/bluetooth" android:layout_height="wrap_content"></ToggleButton>
<TextView android:text="@string/brightness" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/screenbrightness_textview"></TextView>
<SeekBar android:layout_height="wrap_content" android:id="@+id/SbBar" android:layout_width="fill_parent" android:max="255"></SeekBar>          

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

<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:id="@+id/adView"
android:layout_width="fill_parent" 
ads:adSize="BANNER"
ads:adUnitId="a14ddb1a61b9fb4"
ads:loadAdOnCreate="true"
android:visibility="visible"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom" 
android:layout_height="wrap_content" 
android:layout_alignParentTop="false">
</com.google.ads.AdView>

 </RelativeLayout>
 </LinearLayout>
 </ScrollView>
 </LinearLayout> 

Пожалуйста, помогите, спасибо!

РЕДАКТИРОВАТЬ: Изображение

UI рис http://img52.imageshack.us/img52/9397/unledyv.png

Ответы [ 3 ]

3 голосов
/ 02 июня 2011

1) Вы, вероятно, оставите рекламу за пределами прокрутки, чтобы она всегда была видна (в отличие от прокрутки за пределами экрана)

2) Какова цель относительного размещения вокруг рекламы? Это единственный вид внутри него: просто удалите его, и вы получите тот же макет, но лучшую производительность.

На основании обновления я предлагаю вам попробовать этот макет (вам нужно будет заполнить много пробелов):

<RelativeLayout
...
>
<AdView
android:id="@+id/adView"
android:layout_alignParentBottom="true"
...
/>
<ScrollView
android:layout_alignParentTop="true"
android:layout_above="@id/adView"
...
>
<LinearLayout
...
>
...
...
</LinearLayout>
</ScrollView>
</RelativeLayout>

Основная идея состоит в том, чтобы поместить объявление AdView внизу экрана с помощью RelativeLayout, а затем установить ScollView так, чтобы он размещался над объявлениями (чтобы он не блокировал их) и выравнивался по верхней части экрана. 1008 *

1 голос
/ 02 июня 2011

Почему бы вам не попробовать использовать относительный макет в качестве корневого макета.

<RelativeLayout>
<LinearLayout
android:layout_alignParentTop="true">
ETC
</LinearLayout>
<com.google.ads.AdView
android:layout_alignParentBottom="true">
</com.google.ads.AdView>
</RelativeLayout>
0 голосов
/ 15 июля 2012

Чтобы улучшить взаимодействие с пользователем, мы можем переместить объявление за пределы ScrollView и использовать RelativeLayout, чтобы закрепить объявление в нижней части экрана.Это необходимая разметка XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ScrollView android:id="@+id/scrollLayout"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_above="@+id/adView">
        <LinearLayout android:layout_height="fill_parent"
            android:layout_width="fill_parent">
            <TextView android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="Place very long string here..."/>
        </LinearLayout>
    </ScrollView>
    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adUnitId="INSERT_YOUR_AD_UNIT_ID_HERE"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR"
        ads:loadAdOnCreate="true"/>
</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...