【问题标题】:Admob Not Enough Space for Banner AdAdmob 没有足够的空间用于横幅广告
【发布时间】:2015-08-02 19:29:17
【问题描述】:

我不知道如何解决这个问题。我收到错误

空间不足,无法展示广告。需要 360x50 dp,但只有 350x582 dp .

这是我的布局代码:

<LinearLayout 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:gravity="center"
android:padding="5dp"
android:orientation="vertical"
>

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textMultiLine"
    android:maxLines="4"
    android:textSize="20dp" />

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button1"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Copy" />

    <ImageView
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:id="@+id/imageView1"
        android:onClick="keyBoardClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/keyboard" />

    <Button
        android:id="@+id/button2"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Share" />
</LinearLayout>

<GridView
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:gravity="center"
    android:numColumns="8" >
</GridView>

 <com.google.android.gms.ads.AdView
     android:id="@+id/adView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     ads:adSize="SMART_BANNER"
     ads:adUnitId="myAdMobID" >

</com.google.android.gms.ads.AdView>  

那里出了什么问题,因为我在 adView 上有宽度为 match_parent 并为高度包装了内容。

【问题讨论】:

    标签: java android eclipse admob banner


    【解决方案1】:

    AdMob 可能会或可能不会抱怨“有足够的空间”,但如果父视图中有填充,它就不会显示。您需要将想要填充的视图包装在另一个布局中,或者直接向该特定视图添加填充。

    请从父布局中移除内边距:

    <LinearLayout 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:gravity="center"
    android:orientation="vertical"
    >
    

    【讨论】:

    • 哦,这就是问题所在。感谢@Rassel 解决了我的问题! :)
    【解决方案2】:

    您应该使用wrap_content 来表示宽度和高度。

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="myAdMobID" >
    

    【讨论】:

    • 我试过了,而且两者的 wrap_content 都有同样的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    • 2014-02-07
    相关资源
    最近更新 更多