Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – Admob错误:没有足够的空间来展示广告.需要320×50 dp,但只有309×0 dp大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将智能横幅广告投放到我的片段布局中,而我所得到的就是“没有足够的空间展示广告.需要320×50 dp,但只有309×0 dp”.

这是我的片段布局.

<android.support.v4.widget.nestedScrollView
    xmlns:android="http://scheR_937_11845@as.android.com/apk/res/android"
    xmlns:tools="http://scheR_937_11845@as.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:ads="http://scheR_937_11845@as.android.com/apk/res-auto"
    android:scrollbars="vertical"
    android:fillViewport="true"
    xmlns:app="http://scheR_937_11845@as.android.com/apk/res-auto"
    android:id="@+id/details_layout"
    android:BACkground="@android:color/white"
    app:layouT_Behavior="@String/appbar_scrolling_view_behavior"
    tools:context="com.app.bookng.DetailsFragment">

    <RelativeLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/details_relat"
        android:padding="5dp">

        <com.google.android.gms.ads.AdView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:id="@+id/bAnner_id"
            ads:adSize="smaRT_BAnnER"
            ads:adUnitId="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>

        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:indeterminate="true"
            android:id="@+id/progress_circle"
            android:visibility="gone"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_centerInParent="true"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:hint="@String/title"
            android:id="@+id/dbook_title"
            android:visibility="gone"
            android:layout_margin="5dp"
            android:textStyle="bold"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:layout_marginTop="20dp"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:layouT_Below="@+id/dbook_title"
            android:id="@+id/rootauthor_date"
            android:gravity="center_vertical">

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="10dp"
                android:visibility="gone"
                android:BACkground="#d1d1d1"
                android:layout_alignParentTop="true"
                android:id="@+id/dviewtop"
                android:layout_marginTop="15dp"
                android:layout_toRightOf="@+id/author_img"/>


            <com.app.bookng.CircularNetworkImageView
                android:layout_width="90dp"
                android:layout_height="90dp"
                android:visibility="gone"
                android:padding="3dp"
                android:layout_alignParentLeft="true"
                android:id="@+id/author_img"
                android:scaleType="centerCrop"
                android:BACkground="@drawable/round_button"/>

            <TextView
                android:layout_width="wrap_content"
                android:visibility="gone"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/author_img"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:layout_centerVertical="true"
                android:layouT_Below="@+id/dviewtop"
                android:id="@+id/author_date"/>



            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="10dp"
                android:visibility="gone"
                android:BACkground="#d1d1d1"
                android:id="@+id/dviewbottom"
                android:layout_marginTop="10dp"
                android:layouT_Below="@+id/author_date"
                android:layout_toRightOf="@+id/author_img"/>
        </RelativeLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layouT_Below="@+id/rootauthor_date"
            android:hint="@String/main_body"
            android:textColorLink="@color/textlink"
            android:visibility="gone"
            android:id="@+id/dbook_content"
            android:layout_margin="5dp"/>


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/gad_title"
            android:textStyle="bold"
            android:visibility="gone"
            android:textAppearance="?android:attr/textAppearanceMedium"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/gad_pic"
            android:visibility="gone"
            android:layouT_Below="@+id/gad_title"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/gad_feat"
            android:visibility="gone"
            android:layouT_Below="@+id/gad_pic"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:layouT_Below="@+id/gad_feat"
            android:id="@+id/gad_content"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:visibility="gone"
            android:BACkground="#d1d1d1"
            android:id="@+id/viewtop_share"
            android:layouT_Below="@+id/dbook_content"/>


        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layouT_Below="@+id/viewtop_share"
            android:id="@+id/comment_container"/>

    </RelativeLayout>


</android.support.v4.widget.nestedScrollView>

这是活动布局

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://scheR_937_11845@as.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

     //Container for toolbar    
    <include layout="@layout/post_toolbar"/>

    //Container for fragment    
    <include layout="@layout/share_layout"/>


</FrameLayout>

我真的无法弄清楚为什么高度为0dp.你能帮帮我吗?

解决方法

根据Admob文档/指南

广告视图需要具有设备的全宽.
由于您为布局提供了填充,因此无法填充布局的整个宽度.

您只需删除RelativeLayout中的填充即可解决此问题

大佬总结

以上是大佬教程为你收集整理的android – Admob错误:没有足够的空间来展示广告.需要320×50 dp,但只有309×0 dp全部内容,希望文章能够帮你解决android – Admob错误:没有足够的空间来展示广告.需要320×50 dp,但只有309×0 dp所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。