Android Pixel size - dpi - scalefactor


#1

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?


#2

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.


#3

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


#4

This is now fixed on the latest tip.


#5

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

thank you


#6

Great news thanks Fabian and co 


#7

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:

Desktop::getInstance().setGlobalScaleFactor(1.5);                
openGLContext->attachTo(*getTopLevelComponent());
  • 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?


#8

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. 


#9

also see following thread: see http://www.juce.com/forum/topic/setglobalscalingfactor-and-opengl


#10

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?


#11

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.


#12

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.


#13

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


#14

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...

 


#15

Any short-term plan to fix this ?

Thanks