我在我的应用程序中添加了admob,我不是没有足够空间的错误我已经正确设置了admob。这是我的布局文件
<RelativeLayout 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:id="@+id/activity_memo_d_memo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_bg"
android:paddingLeft="@dimen/main_screen_margin"
android:paddingRight="@dimen/main_screen_margin"
android:paddingTop="@dimen/main_screen_margin" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admob_id" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:background="@drawable/main_bg"
android:orientation="vertical" >
<!-- android:background="@drawable/inner_main_bg" -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="73dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="@drawable/main_bg"
android:gravity="center_horizontal"
android:padding="@dimen/component_margin" >
<!-- android:background="@drawable/topbtn_bg" -->
<Button
android:id="@+id/button_new"
style="@style/ButtonTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center|center_horizontal"
android:onClick="NewMemoOnClick"
android:text="NEW" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/component_margin" >
<EditText
android:id="@+id/edit_text_search"
style="@style/EditTextStyle"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/button_all_categories"
android:background="@drawable/search_bg"
android:hint="Search"
android:singleLine="true" />
<Button
android:id="@+id/button_all_categories"
style="@style/SpinnerTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/option_spinner_bg2"
android:onClick="onCategoryMenuClick"
android:text="{All Categories}" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/emptyTextView"
style="@style/DetailsTextStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/list2_bg"
android:gravity="center"
android:text="* Empty *"
android:visibility="gone" />
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent" >
</ListView>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="@drawable/optionmenu_line" />
<LinearLayout
android:id="@+id/activity_main_menu_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/optionmenu_mainbg"
android:orientation="vertical"
android:paddingBottom="@dimen/component_margin"
android:visibility="gone" >
<TextView
android:id="@+id/menu_header"
style="@style/ScreenHeaderStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/component_margin"
android:text="@string/Options" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingRight="4dp" >
<Button
android:id="@+id/menu_button_new_memo"
style="@style/OptionMenuButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onOptionsClickListener"
android:text="@string/action_new_memo" />
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="@drawable/optionmenu_line" />
<Button
android:id="@+id/menu_button_options"
style="@style/OptionMenuButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onOptionsClickListener"
android:text="@string/action_options" />
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="@drawable/optionmenu_line" />
<Button
android:id="@+id/menu_button_about"
style="@style/OptionMenuButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onOptionsClickListener"
android:text="@string/action_about" />
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="@drawable/optionmenu_line" />
<Button
android:id="@+id/menu_button_close"
style="@style/OptionMenuButtonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onOptionsClickListener"
android:text="@string/action_close" />
</LinearLayout>
</LinearLayout>
我在布局文件中使用admob时出现以下错误。
in landscape mode:
10-02 11:14:04.269: W/Ads(19663): Not enough space to show ad. Needs 533x32 dp, but only has 517x254 dp.
答案 0 :(得分:1)
您的广告评论位于使用padddingleft和paddingright的父级相对布局中。 Adview不得有左右填充或边距。另外,将adview的layout_width更改为“match_parent”