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

  • Home
  • SEARCH
  • 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 7411807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:26:39+00:00 2026-05-29T06:26:39+00:00

I am having some problems with the dp calculation for a 7 tablet (800x480px).

  • 0

I am having some problems with the dp calculation for a 7″ tablet (800x480px). Below is my way of calculating. Can’t find where I am making a mistake in calculation or my thought:

I have three devices that I’m testing:

  1. Nexus One: 800x480px, 3.7″ display (specs)
  2. Huawei Ideos: 320x240px, 2.8″ display (specs)
  3. Ainol Novo 7″ Tablet: 800x480px, 7″ display (specs)

Based on the display size, I’m calculating the DPI (dots per inch) manually, based on the formular:

sqrt(w^2 + h^2) / in

So I am getting:

  1. Nexus One: sqrt(800*800+480*480)/3.7 = 252.15dpi
  2. Huawei Ideos: sqrt(320*230+240*240)/2.8 = 142.86dpi
  3. Ainol Novo 7″ Tablet: sqrt(800*800+480*480)/7 = 133.28 dp

Now I want to output the dpi value of the screen metrics and based on that, the screen width and height in dp (density-independent pixels). My code for that is:

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    Log.d(TAG, "ScaledDensity: " + metrics.scaledDensity);
    Log.d(TAG, "Density DPI: " + metrics.densityDpi);

    int widthInPx = 800; // 320 or 800, depending on the respective device width I'm testing
    int widthInDp =(int)(widthInPx/metrics.scaledDensity);
    Log.d(TAG, "width in dp: " + widthInDp);

    int heightInPx = 480; // 240 or 480, depending on the respective device height I'm testing
    int heightInDp =(int)(heightInPx/metrics.scaledDensity);
    Log.d(TAG, "height in dp: " + heightInDp);

Results are as follows:

  1. Nexus One:
    Scaled Density: 1.5, Density DPI: 240, Width in dp: 533, Height in dp: 320
  2. Huawei Ideos:
    ScaledDensity: 0.75, Density DPI: 120, width in dp: 426, height in dp: 320
  3. Ainol Novo 7″ tablet:
    ScaledDensity: 1.0, Density DPI: 160, width in dp: 800, height in dp: 480

The density DPIs that I get from the java code inside my activity differ from my calculated dpi values and are obviously rounded by Android to one of the values 120, 160 or 240, which is quite normal. No problem so far.

Problem/Question 1:

With the third device, the Novo 7″ tablet:
The ScaledDensity is said to be 1.0, and the width in dp is said to be 800, same as the number of px. However, that’s not the reality; when I create a fullscreen app and place a view on there, only 533dp x 320dp of the view actually fit on the screen. So it’s the same dp measurements as the Nexus One; even though the Nexus One has a higher DPI value but the same number of pixels. How is that possible?

Problem/Question 2:

I create an AVD for the emulator, with the exact measurements as the Novo 7″ tablet.
The log lines in my java code show the same values as for the real tablet device:

  1. Ainol Novo 7″ tablet Emulator:
    ScaledDensity: 1.0, Density DPI: 160, width in dp: 800, height in dp: 480

However, on the emulator, I can place a view with 580dp x 320 dp to to fully visible in a fullscreen activity. How is it possible that the width dp differs between the emulator and the real device with exact same measurements?

enter image description here

Problem/Question 3:

On http://developer.android.com/guide/practices/screens_support.html it says:

To help you target some of your designs for different types of

devices, here are some numbers for typical screen widths:

…

480dp: a tweener tablet like the Streak (480×800 mdpi).

600dp: a 7” tablet (600×1024 mdpi).

…

I assume my tablet should fall under one of these categories, however, neither does it have 480 width nor 600 dp width, but something in between; in my case, either 533dp (real device) or 580dp (emulator).

If this is the case, what good does such a ‘typical screen widths’ overview do, if in reality, it doesn’t actually seem to be the case but devices from different vendors can have any other random value in between the standard ones?
Then I could just go ahead and back to working with pixel values again, as the entire benefit of using dp seems to be absent.

  • 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-29T06:26:39+00:00Added an answer on May 29, 2026 at 6:26 am

    Argh, I simply forgot the line

    <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="11" />
    

    in my manifest.

    Without android:minSdkVersion, the are always problems; legacy issues with Android 1.5 I think.

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

Sidebar

Related Questions

I have been having some problems trying to get my PHP running. When I
I'm having some performance problems where a SQL query calculating the average of a
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Im having some problems getting the Sticky Footer to work on my site. If
I'm having some problems integrating MS MapPoint 2009 into my WinForms .Net 2.0 application
I'm having some problems with the ranking used by fulltext search in SQL Server.
I'm having some problems with a datagridview element I'm using in VS2008. This DataGridView
I'm having some problems getting my object to gracefully fail out if an invalid
I'm having some problems with the following code: private class ClientPluginLoader : MarshalByRefObject {
I'm having some problems with my WCF server and client connections. If I use

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.