2014-02-16 2 views
0

В моем макете я показываю объявление внизу. Макет как FrameLayout, где загружается контент, AdView и ListView, чтобы отобразить навигационный ящик.Остановить рекламу от перекрытия последнего элемента ListView

The FrameLayout загружается с ListView и для последней строки ListView не внахлест с рекламой, я создал этот макет:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/lightgrey"> 

    <LinearLayout 
      android:id="@+id/LinearLayout01" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical"> 

     <FrameLayout 
       android:id="@+id/fragmentsboth" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"> 

     </FrameLayout> 

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

      <com.google.android.gms.ads.AdView 
        android:id="@+id/adView" 
        xmlns:ads="http://schemas.android.com/apk/res-auto" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        ads:adUnitId="111111111111111111111111" 
        ads:adSize="SMART_BANNER" 
        android:layout_gravity="center|bottom" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true"/> 
     </LinearLayout> 
    </LinearLayout> 

    <!-- The navigation drawer --> 
    <ListView 
      android:id="@+id/list_slidermenu" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:choiceMode="singleChoice" 
      android:divider="@color/orange" 
      android:dividerHeight="1dp" 
      android:listSelector="@drawable/menulist_selector" 
      android:background="@color/lblack"/> 
</android.support.v4.widget.DrawerLayout> 

Это работает, как ожидалось. Проблема в том, что когда у меня отключена сеть, мой FrameLayout, так как theres no add to show, это не занимает всю высоту экрана. Отображается «пробел» для добавления. В основном он показывает один пустой прямоугольник.

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

ответ

0

Добавлена ​​android:id="@+id/adContainer" в LinearLayout, содержащий объявление и установить его видимость gone и и по коду, сделал это:

adView.setAdListener(new AdListener() { 
     @Override 
     public void onAdLoaded() { 
      super.onAdLoaded(); 
      LinearLayout adContainer = (LinearLayout) findViewById(R.id.adContainer); 
      adContainer.setVisibility(View.VISIBLE); 
     } 
    }); 
Смежные вопросы