Ok… here it is:
The first thing you want to do is define a width that you will use as a reference point. In my case I am developing for portrait orientation and picked 480 x 720 as a reference.
Once the screen is created, grab your scale by doing the following:
float refWidth = 480;
float guiScale = refWidth/screen.getWidth();
Now that you have your scale factor, when you create an element, do the following:
float buttonWidth = 300 * guiScale;
float buttonHeight = 60 * guiScale;
ButtonAdapter ba1 = new ButtonAdapter(screen, UIDUtil.getUID(),
new Vector2f(buttonWidth, buttonHeight)
Another trick is using the pixel width of the ui image… say you have a background image that is a portion of a 1024 x 1024 image (say 1024 x 245) and you need this to fill the top portion of your app. You would:
float headerScale = screen.getWidth()/1024;
header = new Element(
In my case, I need TextElements to accurately display in at certain places in the header image, I chose to use the pixel width in this case, so I could measure out where in the image the text should display and then multiply this by headerScale to have it display in the proper place no matter what device the app is being run on.
Hopefully this is helpful. Do let me know if there are any questions about how I did this.