2014-09-23 62 views
0

圖形佈局添加顯示在底部,但當應用程序運行它不能顯示任何橫幅,並給我警告說.....「沒有足夠的空間來顯示廣告。需要320x50 dp,但只有288x464 。DP「,,,,,,,,任何一個可以解決我的問題....在此先感謝 這裏是XML在android中不顯示admob橫幅和listview?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/mainbg" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" > 
    </ListView> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/game_ads" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="my ad ID" 
     android:gravity="center" /> 

</RelativeLayout> 

enter code here 

回答

0

listview標籤變更

android:layout_alignParentTop="true" 

android:layout_above="@+id/game_ads" 

adview標籤去除android:gravity="center"

即重寫代碼爲

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/mainbg" 
    tools:context=".MainActivity" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/game_ads" > 
    </ListView> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/game_ads" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="my ad ID" 
     /> 

</RelativeLayout> 
+0

對不起,同樣的問題,我正面臨先生:( – MostWant3d 2014-09-23 08:27:52

+0

@ user3326641看到編輯的答案,並清除項目和重試 – 2014-09-23 09:20:37

+0

也乾淨n重新啓動日食,但nothng happpens – MostWant3d 2014-09-23 10:56:39

0

我認爲這應該工作: -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/mainbg" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/game_ads" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="my ad ID" 
     android:gravity="center" /> 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/game_ads" > 
    </ListView> 


</RelativeLayout> 
+0

對不起,同樣的問題,現在面臨先生:( – MostWant3d 2014-09-23 08:27:00

+0

給予高度/寬度與AdMob廣告根據android指南或使用權重方法的小部件。給列表視圖0.6和父母admob並給它0.4的權重。相應地修改它。它會工作 – 2014-09-23 08:33:56

+0

我按你所說的完成,但同樣的問題警告,它顯示在屏幕的1/6列表中,但沒有廣告顯示在應用程序 – MostWant3d 2014-09-23 09:20:04