在android中不使用listview显示admob横幅?
在图形布局中,添加显示在底部,但当应用程序运行时,它不能显示任何横幅并向我发出警告。。。。。“没有足够的空间显示广告。需要320x50 dp,但只有288x464 dp。”,,,,,,,,有人能解决我的问题吗。。。。提前谢谢 这里是XML在android中不使用listview显示admob横幅?,android,listview,layout,admob,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"
<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
在这里输入代码
我认为这应该有效:-
<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>
列表视图中的标记更改
android:layout_alignParentTop="true"
到
并从adview
标签中删除android:gravity=“center”
i、 重写你的代码
<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>
对不起,先生,我面临同样的问题:(根据android指南或使用权重方法为admob小部件指定高度/宽度。为listview指定0.6,为admob指定父级,并为其指定0.4的权重。相应地修改它。它将按照您所说的那样工作,但同样的问题是警告,它在屏幕的1/6处显示列表,但在appxml中再次没有显示广告。当您运行应用程序时,它是可以的,你能看到下面的admob小部件吗?如果是,则代码中有问题。是的,admob小部件以xml显示,但nt在应用程序中运行,在其他布局和活动中,我为admob和其他设置了相同的代码,并显示admob,只是在这个布局中,我面临问题。如果你有时间,谢谢,同样的问题,请自行运行xmlem我面对的是长官:(@user3326641查看编辑的答案,并清除项目,然后重试。也清除n重新启动eclipse,但没有发生任何事情@giru Bhai..我只是删除了填充,它就工作了:)@user3326641很乐意帮助,享受。
<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>