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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:30:02+00:00 2026-06-06T15:30:02+00:00

While developing an application this is what i did : 1.Kept 320*480 as my

  • 0

While developing an application this is what i did :
1.Kept 320*480 as my base resolution and 160dpi as my base density.
2.Kept all the images in drawable-mdpi folder
3.made use of dp while specifying the width and height of the images in xml layouts.

what i found was as its mentioned on the developer’s site if we use dp then it does scaling automatically scales up and scales down according to the screen.But i didn’t got the desired result and the images didnt scaled properly for the smaller device.

So what i did was
1.created the layouts in xml files
2. the set the width and height of the images at runtime in percent of the screen width and height
And by doing this i got the desired result.The images scaled properly on all the devices ranging for small 240*320 to tab 600*1024.

So my question is that as mentioned in the developer site should i use dp for specifying the width and height or should i do it programmatically.And if no what is the concept of dp and where can i use it ?

  • 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-06-06T15:30:05+00:00Added an answer on June 6, 2026 at 3:30 pm

    First thing, I think use of “dp” is good. There is no problem with that.

    Secondly, to cope up with the problem you mentioned, the best way is to put the images of suitable sizes in ldpi, hdpi and xhdpi folders. Then you don’t have to adjust the layouts dynamically.

    The ratio of image sizes in LDPI:MDPI:HDPI:XHDPI= 3:4:6:8

    OR This is how you can predict the size of the device dynamically and then set the layout accordingly:

        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        switch(displayMetrics.densityDpi){ 
            case DisplayMetrics.DENSITY_LOW: 
                //your layout for samll sized devices
                break; 
            case DisplayMetrics.DENSITY_MEDIUM: 
                //your layout for medium sized devices
                break; 
            case DisplayMetrics.DENSITY_HIGH: 
                //your layout for large sized devices
                break; 
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a trick question, while developing a php+ajax application i felt into some
I`m developing this application that need to read every key stroke while the application
While developing an application, I had the following problem. I wanted to return an
While developing a WinForms application, I came across what I believe is a bug
While developing my WordPress application i have a requirement where i need to show
While developing a Launcher (Homescreen) application for Android, I've come into a security exception
I'm having an issue while developing a basic Rails application. I've implemented Twitter Bootstrap
Am Beginner to java.I have a small doubt while i am developing an application
I'm developing an application on two different machines (home and work) and while the
While developing a firefox extension, I create a wizard window from overlay.js using: this.wizard

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.