2015-07-07 5 views
0

Я хочу разместить adMob AdView в нижней части экрана. Но объявления перекрываются в последнем элементе ListView, и я не вижу последний элемент ListView очень хорошо. Если я использую android: layout_below = "@ + id/list_view". Объявления не загружаются!Размещение объявлений admob под списком

Как разместить ListView прямо над AdView?

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <ListView 
      android:id="@+id/list_view" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:scrollingCache="false" 
      android:animationCache="false" 
      android:smoothScrollbar="true" 
      android:stretchMode="columnWidth"> 
     </ListView> 


     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/list_view" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="@string/ads_banner"> 
     </com.google.android.gms.ads.AdView> 


    </RelativeLayout> 
+0

здесь вам нужно добавить android: layout_above = "@ + id/adViewCardItem" в ListView –

ответ

4

Сделайте свой XML как

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

     <com.google.android.gms.ads.AdView 
      xmlns:ads="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/adViewCardItem" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      ads:adSize="BANNER"   
      ads:adUnitId="@string/ads_banner"> 
     </com.google.android.gms.ads.AdView> 

     <ListView 
      android:id="@+id/list_view" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:animationCache="false" 
      android:gravity="center" 
      android:scrollingCache="false" 
      android:smoothScrollbar="true" 
      android:layout_above="@+id/adViewCardItem" 
      android:stretchMode="columnWidth" > 
     </ListView> 

     </RelativeLayout> 
0

эй вы можете попробовать некоторые вещи, как этот

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

<com.google.android.gms.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/adViewCardItem" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@id/list_view" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/ads_banner"> 
</com.google.android.gms.ads.AdView> 

<ListView 
    android:id="@+id/list_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:animationCache="false" 
    android:gravity="center" 
    android:paddingBottom="150dip" 
    android:scrollingCache="false" 
    android:smoothScrollbar="true" 
    android:stretchMode="columnWidth" > 
</ListView> 

1

Он должен работать отлично

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

    <ListView 
     android:id="@+id/list_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:scrollingCache="false" 
     android:animationCache="false" 
     android:smoothScrollbar="true" 
     android:stretchMode="columnWidth"> 
    </ListView> 


    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="SMART_BANNER" 
     android:layout_weight="0" 
     ads:adUnitId="@string/ads_banner"> 
    </com.google.android.gms.ads.AdView> 


</LinearLayout> 
+0

Благодарим вас за редактирование William. –

Смежные вопросы