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 6222269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:17:09+00:00 2026-05-24T08:17:09+00:00

Here is the thing, as you might know Admob has a AdSize.* function, where

  • 0

Here is the thing, as you might know Admob has a AdSize.* function, where u put Banner to show banner ads, and AD_banner` for tablet banners, what i want to do is take a screen size of a device so that i could throw it in my if statement and then put the right banner for right device, i hope i was clear enough.So anyone can tell me how can i get the screen size of device?
Thank u
//////////
Here’s what i have done so far

     DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);

       if (dm.density==DisplayMetrics.DENSITY_HIGH) {
        AdView adView = new AdView(this, AdSize.BANNER,s);
        LinearLayout layout = (LinearLayout)findViewById(R.id.admob);
        layout.addView(adView);
        adView.loadAd(new AdRequest());
       }
       if (dm.density==DisplayMetrics.DENSITY_DEFAULT || dm.density==DisplayMetrics.DENSITY_LOW ) {
             AdView adView = new AdView(this, AdSize.BANNER,s);
             LinearLayout layout = (LinearLayout)findViewById(R.id.admob);
             layout.addView(adView);
            adView.loadAd(new AdRequest());

        }
        if(dm.density==DisplayMetrics.DENSITY_MEDIUM)
        {
            AdView adView = new AdView(this, AdSize.IAB_BANNER,s);
            LinearLayout layout = (LinearLayout)findViewById(R.id.admob);
            layout.addView(adView);
            adView.loadAd(new AdRequest());

        }
  • 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-24T08:17:10+00:00Added an answer on May 24, 2026 at 8:17 am

    If your layout is define in a xml, you can create one layout per screen size (layout-xlarge/mylayout.xml, layout-large/mylayout.xml, layout-normal/mylayout.xml, etc…)

    More info here : http://developer.android.com/guide/practices/screens_support.html

    Don’t look at density, because, a 10.1″ tablet has a medium density, but a 4.3″ phone with a 480×850 resolution will have a high density. Use screen size instead (xlarge large normal small).

    If you need to do it programatically, you can get the screen size with this :

    Configuration config = activity.getResources().getConfiguration();
    int screenlayout = config.screenLayout;
    

    and to compare, use Configuration.SCREENLAYOUT_xxx .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the thing: object[] arrayText = new object[1]; if (arrayText[1] == null) { MessageBox.Show(Is
i didn't really know how to title this question, but here's a thing that
I know some basic regexp, but here's the thing. Every charachter will be enclosed
And what if you want to autocomplete passwords? I am using similar thing here...
Here's the thing: I have two applications, written in C++ and running on two
Here is the thing. Right now I have this e-commerce web site where people
Here's the thing: In my Qt4.6-Project, I use a SQLite-Database. This database shouldn't be
Here is the thing. I currently have a tabBar controller, with several navigation controllers
I'm triying to do exactly the same thing described here , but in VB.NET
Ok, here's the thing. I've done a webpage which contains forms and so I

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.