Any basic example on dealing with different DPI screens?

edited November 2013 in Android Mode

Hello again... I've been reading about this topic (here, and here) , however I'm a bit confused about implementing that on Processing.

is there any basic example of usage I could see somewhere? maybe drawing a simple rectangle and how should I proceed to make it size-compatible with any device...

cheers guys!

Answers

  • In case it's any help, I achieved this by making every measurement in my app a proportion of the total screen size. This type of thing:

    textSize(height/10); image(logoIcon, width/24, height/25);

    It's a bit long-winded but the results are at least consistent across most devices. You might just need to be aware of menu bars getting in the way depending on the API level.

  • try..

            //in all my small projects use only one coordinate for both x and y
           // example:
                    size (displayWidth, displayWidth)
                    //you enter the objects on the screen and you see, is rectangular.
                    // or displayWidth, displayHeight);//  to position objects
    
                    translate (width / 2, width / 3);
                    ellipse (0,0, width/10, width/10);
    
  • thanks! I forgot to mention that I've already tried that. it's an effective way. However if screen is rotated width is height, and height is width, and viceversa.

    Maybe I should think about asking if screen is in Landscape or Portrait View at the beggining of draw() function. Or as final option, force the screen in one of both.

  • edited November 2013

    The problem with declaring sizes proportionally in width and heigth, is that if you make a button "height/4" length, it would make sense on a very small display, but it would be huge on a large one...

Sign In or Register to comment.