在android中没有显示带有listview的admob横幅?

时间:2014-09-23 07:47:31

标签: android listview layout admob

在图形布局中,添加显示在底部,但是当应用程序运行时,它无法显示任何横幅并向我发出警告....."没有足够的空间来展示广告。需要320x50 dp,但只有288x464 dp。 " ,,,,,,,,,任何人都可以解决我的问题....提前感谢 这是XML

<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

2 个答案:

答案 0 :(得分: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> 

答案 1 :(得分:0)

listview代码更改

android:layout_alignParentTop="true"

android:layout_above="@+id/game_ads"

并从android:gravity="center"代码

中删除adview

即。将代码重写为

<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>