[英]Admob Not Enough Space for Banner Ad
我不知道如何解决此问题。 我遇到错误
没有足够的空间来展示广告。 需要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的宽度,而包装内容是高度。
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"
>
您应该同时使用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" >
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.