I've ended up putting all the MMedia related code to the xml file and wrapping it with android:layout_width="480dp" android:layout_height="60dp"
White rectangular space in Millennial Media 5.0 Android
-
04-04-2022 - |
Question
The white rectangular area (which cover whole screen when MMedia banner is displayed) exists on devices with Android 4.0+ while using only the pure Java code. Adding lines which specify width and height doesn't fix a thing (white screen still persists). Hope the issue will get investigated by Millennial team. Cheers
MMSDK.initialize(this);
millennialView = new MMAdView(this);
millennialView.setApid(MILLENNIAL_BANNER_ID);
millennialView.setId(MMSDK.getDefaultAdId());
RelativeLayout.LayoutParams lay2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lay2.addRule(RelativeLayout.ALIGN_PARENT_TOP);
layout.addView(millennialView, lay2);
Map<String, String> metaData = new HashMap<String, String>();
metaData.put("width", "480");
metaData.put("height", "60");
MMRequest mmediaRequest = new MMRequest();
mmediaRequest.setMetaValues(metaData);
millennialView.setMMRequest(mmediaRequest);
millennialView.setListener(getMillennialListener());
millennialView.getAd();
Solution
OTHER TIPS
Same problem in latest MMedia APi 5.2.
I use a list view to attach the Adview. Using match content for the height.
After some testing I found that the banner ad only takes the whole screen in Android 4.04 on the devices that I have. 4.4 and Gingerbread seem to be ok.
Here is my code to get around the problem:
float density = getResources().getDisplayMetrics().density;
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
height = display.getHeight();
width = display.getWidth();
} else {
Point size = new Point();
display.getSize(size);
height = size.y;
width = size.x;
}
LinearLayout layout = (LinearLayout)findViewById(R.id.llBannerAd);
if (width/density > 727 && height/density > 600) {
mAdView.setAdSize(AdSize.LEADERBOARD);
layout.setLayoutParams(new LinearLayout.LayoutParams(width, 91));
} else if (width/density > 467 && height/density > 400) {
mAdView.setAdSize(AdSize.FULL_BANNER);
layout.setLayoutParams(new LinearLayout.LayoutParams(width,61));
} else {
mAdView.setAdSize(AdSize.BANNER);
layout.setLayoutParams(new LinearLayout.LayoutParams(width, 55));
}
This is related to the MMAdView's size when it's applied to a layout hierarchy. The MMAdView doesn't recognize WRAP_CONTENT due to internal changes in its WebView. As such, Millennial's documentation asks that you explicitly set the ad size. See step two here: http://docs.millennialmedia.com/android-SDK/AndroidBannerAds.html
An interesting side-effect: if you're using a mediation partner (AdMob or MoPub, for instance), the same must be done for their banner view widgets (AdView and MoPubView, respectively).