Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4581904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:59:44+00:00 2026-05-21T20:59:44+00:00

So, with new google-admob SDK for android correct way to place banner ad in

  • 0

So, with new google-admob SDK for android correct way to place banner ad in the layout is for example like this :

<com.google.ads.AdView android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_gravity="bottom"
    android:layout_height="wrap_content"
    ads:adUnitId="some id"
    ads:adSize="BANNER"/>

My problem is that I have multiple banner ads throughout various activities and when I for some reason want to change adUnitId I do not want to chase this snippet of code through all my xml layout files. I want to have one place where I define my adUnitId that all banner ads in the app uses. That was possible in the previous admob-only SDK, by setting meta data in manifest file. And I do not want to layout AdView in Java code, want it to be in xml if possible with the new SDK.
I tried with something like this :

ads:adUnitId="@string/admob_id"

but it just see it as a string as I can see, not following through to the actual string defined in the strings.xml. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:59:45+00:00Added an answer on May 21, 2026 at 8:59 pm

    With the newest admob update, I was forced to do most of my AdMob activities in my Java classes. This is how I made it work (with a centralized ID):

    ad = new AdView(this, AdSize.BANNER, UtilClass.AD_PUBLISHER_ID); //Ad is the global AdView
    LinearLayout layout = (LinearLayout) findViewById(R.id.main_admob_layout);
    

    Edit: I keep the LinearLayout definition in the xml files so the positioning is all done throughout the xml:

    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:gravity="bottom" android:weightSum="0"
        android:layout_alignParentBottom="true" android:id="@+id/main_admob_layout">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the new 15 version android sdk and the new admob sdk. On
I've got my AdMob code implemented into my XML file like this: <?xml version=1.0
Using Google's new Charts is a wonderful way to build graphicial representations of data,
I'm trying to integrate an admob banner into my Android game. I have a
I have a service variable that is initialized : service = new google.gdata.calendar.CalendarService('timeless'); This
I have this javascript, if ( $.cookie(latlng) ) { myLatlng = new google.maps.LatLng( $.cookie(latlng)
Google has this fine new Google Maps API v3 which is a Javascript API.
i am trying to run google map tutorial using following link http://mobiforge.com/developing/story/using-google-maps-android followed all
Hello I am new to android dev and admob. I am trying to make
The new Google Music app looks like it is using the new action bar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.