Admob mediation: How to show banners from all network at the same place?

104 views
Skip to first unread message

Viral

unread,
Mar 24, 2014, 3:33:09 AM3/24/14
to google-adm...@googlegroups.com
I have admob and another network configured in admob mediation for my app. When admob renders the ad it shows fine (as expected) at the bottom of the screen. But when the other network renders the banner, the banner shows at the top of the screen. The problem is that when this happens, the entire content of the app is hidden because the adview for some reason resizes to take on the full height of the screen. Earlier i though this was because I was using smart banners. So i switched to regular banners but the issue persists. This is seen to be happening only on 7" tabs. On normal mobile phones it shows the banner at the bottom. 

Is there a way to configure the position of the banner for all networks when using admob mediation? Need urgent help with this.

Amy Quispe (AdMob SDK Team)

unread,
Mar 24, 2014, 7:58:35 PM3/24/14
to google-adm...@googlegroups.com
Hi Viral,

What mediation network are you using? It's probably a particular mediation network's ads that are causing the problem - you can let them know by filling out the correct support ticket here. You can also try using a fixed height instead of wrap_content to prevent this from happening.

Hope this helps!

Amy Quispe

Viral

unread,
Mar 26, 2014, 3:23:28 AM3/26/14
to google-adm...@googlegroups.com
Hi Amy,

Yes, the network is millennial media. I created a support ticket with them and the gave the following information:
  • Smart banners in admob mediation isnt supproted by them. So, i switched back to normal banners but the adview going full screen persists.
  • For the adview height problem, they said that we need to explicitly set the size of the adview as described in step 2 here. But in the Adview object (when using admob mediation) there does not seem to be a way to explicitly specify width and height. Am i missing something ?

Following is my code:

    // Create the adView
    adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId(cd.getBannerAdmobMediationID());

    // Lookup your LinearLayout assuming its been given
    // the attribute android:id="@+id/mainLayout"
    LinearLayout layout = (LinearLayout) findViewById(R.id.layoutNewsPapers);

    // Add the adView to it
    layout.addView(adView);

    // Initiate a generic request to load it with an ad
    String newsAdYearStr = getSavedPreferences("newsAdYear");
    String newsAdGender = getSavedPreferences("newsAdGender");

    AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
    adRequestBuilder.addTestDevice("abcdefghi");
    if(newsAdYearStr.trim().length() > 0) adRequestBuilder.setBirthday(new GregorianCalendar(Integer.parseInt(newsAdYearStr), 1, 1).getTime());
    if(newsAdGender.equalsIgnoreCase("M")) adRequestBuilder.setGender(AdRequest.GENDER_MALE);
    if(newsAdGender.equalsIgnoreCase("F")) adRequestBuilder.setGender(AdRequest.GENDER_FEMALE);

    AdRequest adRequest = adRequestBuilder.build();

    adView.loadAd(adRequest);

The layout file is as follows:

<LinearLayout android:id="@+id/layoutMain"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">

        <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/ClrBlack" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="10sp"
            android:gravity="center_horizontal"
            android:padding="2dp" 
            android:layout_margin="5dip">
                <TextView
                android:id="@+id/textInstruct"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center_horizontal"
                android:text="@string/selectStateTxt" />
        </TableRow>
    </TableLayout>

    <ListView
        android:id="@+id/listView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >
    </ListView>

</LinearLayout>

What is going wrong?

Viral

unread,
Mar 26, 2014, 3:35:20 AM3/26/14
to google-adm...@googlegroups.com
Basically, In Admob's adview, there are no methods to set the height and width separately from what i found (This is what they describe, in the link above, to be used with their MMAdview object). Admob's adview just has a setAdSize method which accepts AdSize.BANNER, AdSize.SMART_BANNER etc. Is there a way to not use a predetermined AdSize value and provide the width and height separately? If I'm able to do this i think the Adview height issue can be handled.

Amy Quispe (AdMob SDK Team)

unread,
Mar 27, 2014, 6:06:27 PM3/27/14
to google-adm...@googlegroups.com
Hi Viral,

An AdView is still just a view. You can set android:layout_width and android:layout_height in the xml. This sets the size of the view, which isn't the same as setting the "adSize" parameter. Try doing that.

Amy Quispe

ATravis

unread,
Jun 13, 2014, 11:13:50 AM6/13/14
to google-adm...@googlegroups.com
Viral,

The Millennial Media SDK does not support wrap_content.  The layout_height and layout_width should be explicitly defined.  Here is an example using BANNER ad size:

        android:layout_width="320dp"
        android:layout_height="50dp"
Reply all
Reply to author
Forward
0 new messages