2015-01-01 2 views
0

я следующий 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> 

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

Должен ли я плавать объявление над веб-просмотром или над родительским Linringayout ??

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

+0

Почему ваш веб-просмотр охватывает весь экран при использовании относительной компоновки? Вы можете установить его высоту. – SLee

ответ

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> 
Смежные вопросы