Android Pixel size - dpi - scalefactor

I´m trying to create an app on both ios and android.

ios seems to work ok, but on my android device (HTC One M8) the UI and text is super-small.

The app fills the entire screen but everything is very small.

fo laying out my buttons / text I use relative values (for example a button that covers 50% of the height)

But something is cleary wrong since text is very small etc.

What is the thing to do here?

I tried to mess with Desktop::setGlobalScaleFactor() but that  does not seem to work.

I though I could figure something out based on the dpi values.

Anyone has any ideas about this?

After looking at it a bit more, I´m not even sure what I´m asking for blush

I guess i'm looking for a "best-practise" tip for makeing the ui look about the same on each platform,. First priority is to make the fonts bigger, and consistent.

We have a fix for this problem and we will push it to master once Jules has got a chance to review the code.

This is now fixed on the latest tip.

Thank you for the fast update. Tested and it works GREAT!

thank you

Great news thanks Fabian and co 

Tank you. But it seems not to work right with OpenGL.

I try to use an OpenGLContext for the top level component. So in the constructor of the main window i call:

  • The display renders wrong scaled, while mouse handling uses the scale factor.
  • The problem occured on both of my target platforms, Windows and Andoid.

See the following screenshots (left with opengl, right how it looks without openGL).

(Also notice where the mouse cursor is positioned to highlight the upper right menu button.)

Wrong, with OpenGL context: Right, without OpenGL (how it should be):
wrong rendering, using OpenGL right without opengl

Is it possible to fix this?

I can confirm this is working for me. Now it looks much closer to what I see on my Mac and Introjucer, i.e. not so small. 

also see following thread: see

I've just hit the same problem as mentioned above. I'm using JUCE 4.02 and Android 5.1.1. Calling Desktop::getInstance().setGlobalScaleFactor() with anything but a 1 moves and reszies my OpenGL window to the top right hand corner of my handset. It works fine with the software renderer, so I'm sure my scaling factors are correct. Any ideas?

This sounds like a JUCE bug. I'll have a look at it. It only seems to occur if you change the defaultScale factor manually via setGlobalScaleFactor.


In the mean time you can set the default scaling factor by changing the calculation on line juce_gui_basics/native/juce_android_Windowing.cpp:744. This seems to work for me.

I'm glad you think it may be bug. I was beginning to doubt myself! For now I'm dynamically resizing all components which works, but is not ideal. Please let us know when you find a fix. Thank you.

Any movement on this? Can you at least confirm there is something afoot here? Thanks. 

Yeah as Fabian says you can workaround this by forcing the d.scale value in the findDisplays method (the line # that Fabian gave is not good anymore).

It would be great that this be fixed, however, as it is an important feature to develop cross-platform...


Any short-term plan to fix this ?