这是我的XML布局代码,它给出了空间不足的错误。似乎宽度还不够大,我觉得这很奇怪。
没有足够的空间来显示添加!想要有这是logcat中的错误。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/backgr2"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:textColor="#fff"
android:text="Some Text" />
Maybe this gridview takes too much of the screen?
<GridView
android:id="@+id/gridView1"
android:layout_below="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="131dp"
android:background="@drawable/bakgr"
android:gravity="center"
android:horizontalSpacing="0dp"
android:numColumns="3"
android:verticalSpacing="5dp" >
</GridView>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridView1"
android:textSize="20sp"
android:textStyle="italic"
android:text="Some Text" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/gridView1"
android:layout_marginBottom="40dp"
android:background="@drawable/button_state"
/>
This is the adview which cannot be displayed for I dont know what reason!
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adUnitId="XXXX"
ads:testDevice="TEST_EMULATOR"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</RelativeLayout>
是的..请帮助
最佳答案
问题是在根元素中指定的RelativeLayout填充。它也会影响AdView,这就是您收到此错误的原因。
将填充专门移到需要的填充上,或将这些元素包装在其他LinearLayout中,并为其提供所需的填充。