我对Adhury中显示的广告有一些问题。
我在那里展示千禧一代媒体和Admob的广告。
Admob看起来不错,但当加载MM广告时,看起来广告太长了。
我试图用某些方法修复它,但无法修复。
这是我为Adhury编写的Java代码:
LinearLayout layout = (LinearLayout) findViewById(R.id.layout_main);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "apid");
RelativeLayout.LayoutParams adWhirlLayoutParams =
new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
int diWidth = 320;
int diHeight = 53;
float density = getResources().getDisplayMetrics().density;
adWhirlLayout.setMaxWidth((int)(diWidth * density + 0.5f));
adWhirlLayout.setMaxHeight((int)(diHeight * density + 0.5f));
layout.addView(adWhirlLayout, adWhirlLayoutParams);
layout.invalidate();
如果有人知道如何修理,请帮忙。
编辑:
我正在开发HTC Desire,也尝试在xml中创建adhury布局,但仍然存在相同的问题;(
我尝试将MM布局添加到xml中,使用参数app:width="320"看起来不错。默认值为480,使用此值,广告看起来类似于adhury实现(太长)
xmlns:app="http://millennialmedia.com/android/schema"
<com.millennialmedia.android.MMAdView
android:id="@+id/mmadview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:apid="28911"
app:adType="MMBannerAdTop"
app:refreshInterval="30"
app:accelerate="true"
app:ignoreDensityScaling="false"
app:age="46"
app:gender="female"
app:zip="90210"
app:income="85000"
app:keywords="moms,shopping,groceries"
app:ethnicity="hispanic"
app:orientation="straight"
app:marital="married"
app:children="2"
app:education="college"
app:politics="libertarian"
app:height="60"
app:width="480" /> <------------------------------------HERE
也许有可能在adwrist布局中设置这个值?
编辑2:
看起来480x800设备的分辨率有问题。我在QVGA 320x240模拟器上调试了应用程序,广告看起来很不错。
编辑3:
它看起来像链接中的图片:Adhury Layout 中的MM广告太长
当广告出现时,我可以看到水平滚动条,我想我只能看到这些广告的2/3
我想知道计算宽度和高度是否有问题。试试这个基本片段:
LinearLayout layout = (LinearLayout) findViewById(R.id.layout_main);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "apid");
layout.addView(adWhirlLayout);
更新:
您也可以通过XML创建AdWhirlLayout。
<com.adwhirl.AdWhirlLayout
android:id="@+id/adwhirl_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
AdWhirl通过在清单中查找以下片段获得您的SDK密钥:
<meta-data android:value="YOUR_SDK_KEY"
android:name="ADWHIRL_KEY" />
更新2:
因此,根据千禧一代的文档,建议您不要设置高度或宽度,而是让SDK根据设备进行优化。HTC Desire的屏幕密度为1.5,因此320x53的广告应该放大到480x79.5。这就解释了为什么默认为480。我仍然不知道为什么它太长。它应该非常合身。当你说太长时,它是太长了几个像素,还是太长了1.5倍?
更新3:
所以我实际上能够重现这个问题,这看起来像是千禧一代的一个bug。我不确定这是否只是创意,因为我只能得到那个确切的广告,但那个广告肯定是480dp宽的,而它应该只有480px宽。如果你把你的设备放在横向模式,你可以看到它有多大。
我建议联系千禧一代,问他们以前是否见过这个问题。