Android将ad-mob广告的宽度调整为屏幕宽度的70%

时间:2014-02-06 07:45:59

标签: android android-layout admob

我想将广告的广告大小修改为屏幕的70%,如图所示。我尝试了,通过改变布局

enter image description here

布局

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

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        android:layout_weight="0.7" >

    </com.google.ads.AdView>

    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.3"
        android:background="#00FF00"
        >

         <ImageView
             android:id="@+id/imageView1"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:src="@drawable/logo" />

    </LinearLayout>

这个XML在大屏幕上运行良好但是小屏幕问题。在小屏幕中,它不显示并给出错误。

02-05 19:21:59.265: E/Ads(11210): Not enough space to show ad! Wants: <480, 75>, Has: <106, 636>
02-05 19:21:59.266: E/Ads(11210): Not enough space to show ad! Wants: <480, 75>, Has: <336, 636>
02-05 19:21:59.267: E/Ads(11210): Not enough space to show ad! Wants: <480, 75>, Has: <106, 636>
02-05 19:21:59.269: E/Ads(11210): Not enough space to show ad! Wants: <480, 75>, Has: <336, 636>

是否有可能修改要求&lt; 480,75&gt;做广告??

1 个答案:

答案 0 :(得分:0)

尝试将ads:adSize="BANNER"更改为ads:adSize="SMART_BANNER"并在代码中

AdView adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);