Java Android没有足够的空间显示广告-admob
我知道这个问题有很多答案,我已经尝试了大部分的解决方案,但目前还没有找到解决方案 我试图在我的Android活动上显示一则广告,我一直收到这条消息Java Android没有足够的空间显示广告-admob,java,android,xml,admob,smartbanner,Java,Android,Xml,Admob,Smartbanner,我知道这个问题有很多答案,我已经尝试了大部分的解决方案,但目前还没有找到解决方案 我试图在我的Android活动上显示一则广告,我一直收到这条消息 Not enough space to show ad. Needs 480x75 pixels, but only has 480x0 pixels. 我的活动XML文件如下所示: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.co
Not enough space to show ad. Needs 480x75 pixels, but only has 480x0 pixels.
我的活动XML文件如下所示:
<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" >
<LinearLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="***"
ads:adSize="BANNER"/>
</LinearLayout>
<ListView
android:id="@+id/listview_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
我似乎无法在屏幕上显示它。
有人能帮我吗
提前谢谢
更新
我使用RelativeLayout成功地做到了这一点,我就是这样做到的:
<RelativeLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adView" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
app:adSize="BANNER"
app:adUnitId="****" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>
这很可能是因为您的列表视图的高度设置为match\u parent
。请尝试将其更改为0dp和layout\u weight=“1”set layout\u height=“0dp”和layout\u weight=“1”,我的导航抽屉不会显示,并且仍然从admob收到相同的消息:(作为最后手段,您可以手动设置横幅高度。根据横幅的大小,横幅的大小为320x50。如果您为adView
设置android:layout\u height=“50dp”
属性,系统将使用系数1.5缩放高度(来自您收到的警告)。因此,高度将为50*1.5=75 px。请在Onik处尝试,但在加载FrameLayout时,其高度将覆盖所有屏幕,并且广告不可见。
<RelativeLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adView" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
app:adSize="BANNER"
app:adUnitId="****" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>