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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:35:55+00:00 2026-06-11T00:35:55+00:00

I am new to phonegap and facing a problem, I am making a phonegap

  • 0

I am new to phonegap and facing a problem, I am making a phonegap app which will run on multiple platform devices of different screen size and different screen resolution so I have to load images of different resolution depending on screen resolution.

this can be achieved in android by simply putting your images of different resolution in hdpi, mdpi and ldpi folder and it(android) fetches images automatically depending on devices screen resolution. But how to do this in phonegap.

I have seen lot of articles on responsive web design they all say about positioning the elements on web page but non of them has told about how to place images on the basis of screen resolutions.

thanks i advance.

edited question

i have used following code for html

<div id="header" data-role="header" data-position="fixed">
 <img alt="app_icon" src="pictures/app_logo.png" display="inline" class="align-left" />
 <img alt="brand_icon" src="pictures/company_logo.png" display="inline" class="align-right" /><h1></h1>
</div>

now I have images inside assets/www/pictures folder. this folder consists of 2 images of same resolution app_logo.png and company_logo.png and 2 images of higher resolution app_logo_big.png and company_logo_big.png now through media queries i will know the screen size and apply the styles but as far as i know i cannot change img src from css. So now how will i use these images of different resolution

  • 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-11T00:35:56+00:00Added an answer on June 11, 2026 at 12:35 am

    Then Dynamically Change Image through jquery:

    HTML:

    <div id="header" data-role="header" data-position="fixed">
       <img id="app-icon" src="pictures/app_logo.png" display="inline" />
    </div>
    

    Javascript:

    $(document).ready(function () {
      if(window.devicePixelRatio == 0.75) {
         $("#app-icon").attr('src', '/images/lpdi/app-icon.png');   
      }
      else if(window.devicePixelRatio == 1) {
               $("#app-icon").attr('src', '/images/mdi/app-icon.png');  
      }
      else if(window.devicePixelRatio == 1.5) {
         $("#app-icon").attr('src', '/images/hpdi/app-icon.png');   
      }
      else if(window.devicePixelRatio == 2) {
                  $("#app-icon").attr('src', '/images/xpdi/app-icon.png');  
      }
    }
    

    Through CSS: Use Media Queries for Different Resolution :

    HTML:

    <div id="header" data-role="header" data-position="fixed">
        <span id="app-icon"></div>
        <span id="brand-icon"></div>
    </div>
    

    CSS:

    /* Low density (120), mdpi */
    @media screen and (-webkit-device-pixel-ratio: 0.75) {
       #app-icon { background-image:url(pictures/ldpi/app-icon.png); }
       #brand-icon { background-image:url(pictures/ldpi/brand-icon.png); }
    }
       
    /* Medium density (160), mdpi */
    @media screen and (-webkit-device-pixel-ratio: 1) {
       #app-icon { background-image:url(pictures/mpi/app-icon.png); }
       #brand-icon { background-image:url(pictures/mdpi/brand-icon.png); }
    }
    
    /* High density (240), hdpi */
    @media screen and (-webkit-device-pixel-ratio: 1.5) {
       #app-icon { background-image:url(pictures/hdpi/app-icon.png); }
       #brand-icon { background-image:url(pictures/hdpi/brand-icon.png); }
    }
    
    /* Extra high density (320), xhdpi */
    @media screen and (-webkit-device-pixel-ratio: 2) {
       #app-icon { background-image:url(pictures/xdpi/app-icon.png); }
       #brand-icon { background-image:url(pictures/xdpi/brand-icon.png); }
    }
    

    If you want to filter through,

    ORIENTATION – and (orientation: landscape)

    Device WIDTH and (min-device-width : 480px) and (max-device-width : 854px)

    Example:

    @media screen and (-webkit-device-pixel-ratio: 1.5) and (min-device-width : 640px) and (max-device-width : 960px) and (orientation: landscape) {
       /* Your style here */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to phonegap development and currently developing an app that will run
I am new to phonegap. I am using phonegap with IOS. the problem i
I am new in phonegap development. I have one html page which contains one
I'm a new to phonegap and are having a problem opening the native google
I am building a phonegap app for iOS which works perfectly and beautifully except
I am new in phonegap .I have two text field which contains mobile n.
I am creating a new app using phonegap (html and javascript) and am using
I´m new to PhoneGap/CoffeeScript trying to get a Hello World App running in iOS
I'm new in android. and i'm making an application in phonegap. There is an
I am new to PhoneGap, and I am building an app using PhoneGap +

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.