mohammedali sunasara
mohammedali sunasara

Reputation: 220

not enough space to show admob in android

I am adding admob in my application and i am not this error of not enough space i have already set the admob properly. Here is my layout file

<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>

And i am getting following error in using admob in my layout file.

 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.

Upvotes: 0

Views: 92

Answers (1)

jomartigcal
jomartigcal

Reputation: 813

Your adview is inside the parent relative layout with padddingleft and paddingright. Adview must not have left and right padding or margin. Also, change adview's layout_width to "match_parent"

Upvotes: 1

Related Questions