我不知道如何解决这个问题。我收到错误
Not enough space to show ad. Needs 360x50 dp, but only has 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 可能会或可能不会提示“有足够的空间”,但如果父 View 中有填充,它就不会显示。您需要将想要有填充的 View 包装在另一个布局中,或者直接向该特定 View 添加填充。
请从父布局中删除内边距:
<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"
>
关于java - Admob 横幅广告空间不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31775760/