BACKGROUND:
JavaFX offers multiple layout classes in order to design responsive applications. Sometimes, things like paddings and spacings have to be specified (in px) in order to keep application in good visual shape. Things like fonts are dpi-aware, so we don't have to worry about the sizes of such.
PROBLEM:
Paddings specified in pixels are not dpi-aware, will be always the same.
POTENTIAL SOLUTIONS:
- Calculate paddings and spacings in relation to screen size, eg.
public static double calculate(double sizeOnFullHdScreen) {
return (SCREEN_PIXELS / FULL_HD_SCREEN_PIXELS) * sizeOnFullHdScreen;
}
- Using invisible texts (as mentioned earlier, fonts and texts are dpi-aware)
QUESTION:
Is there any better solution than proposed?