google.ads.AdView not take the full width of screen in samsung galaxy notes

AndroidDev picture AndroidDev · May 9, 2012 · Viewed 8.1k times · Source

I am displaying a google.ads.AdView in my app at the bottom of the screen. All works fine. But the only problem is that it doesn't take the full width of the screen while showing in Samsung galaxy note, however while displaying in Nexus s it takes the full width of the screen.

Why this happens, is there is a way to solve this issue?

My XML Layout where I put my google.ads.AdView is:

<LinearLayout
    android:id="@+id/bottom_control_bar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="a14e5222d46c63d"
        ads:loadAdOnCreate="true" >
    </com.google.ads.AdView>
</LinearLayout>

Answer

Rajesh picture Rajesh · May 9, 2012

The width of the AdView varies depending on the attribute adSize. You can check the various values for this attribute in https://developers.google.com/mobile-ads-sdk/docs/admob/android/banner#banner_size. You can use the SMART_BANNER constant in case you are using v6.0.0 or later of AbMob.

    <com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     ads:adUnitId="yourAdUnitId"                         
                     ads:adSize="SMART_BANNER"
                     ads:loadAdOnCreate="true"/>