Which size of fxml gui is right? - gluon-mobile

I have problems with gluon-mobile view sizing FXML, it use a different size I'm confused.
in the sample gluon-mobile it uses 350 x Height 600.
But in the scene builder File-> new Template it creates with 335 x Height 600
both Template.
I need it for setup my Adobe XD for design the background image.
Can it be specified?

Those sizes (350x600, 335x600) are set for reference, and to test on desktop, based on usual mobile formats, but the real size will be defined by the real device, and this can vary.
See for instance https://material.io/tools/devices/, where you can find several devices with 360x640 dp, but many other resolutions as well.
When you display your view with Gluon Mobile on a real device, the scene will take the full available size.
If you want to retrieve this value, you can use the DisplayService (see doc):
Services.get(DisplayService.class).ifPresent(service -> {
// screen resolution of the device, in pixels
Dimension2D resolution = service.getScreenResolution();
System.out.printf("Screen resolution: %.0fx%.0f", resolution.getWidth(), resolution.getHeight());
// default screen dimensions of a mobile device, in dp
Dimension2D dimensions = service.getDefaultDimensions();
System.out.printf("Screen dimensions: %.0fx%.0f", dimensions.getWidth(), dimensions.getHeight());
});
If you want to use an image for the background, you can use css to set it to expand or adjust properly to the final size, as documented here for -fx-background-image.

ok, it's mean that I need export design img in all sizes like to
mipmap-hdpi
mipmap-ldpi
...
mipmap-xxxhdpi
?

Related

How to scale fontsize on different devices programmatically (Xamarin.android)?

I'm new to Xamarin and I'm actually developing an Android App. I've tried to run the app on different Android phones, but the fontSize appears either too small or large. Programmatically, how can I scale the FontSize of texts so that it can be adjust according to the device's screen?
Firstly, make sure you are using sizes in dp not px (or in, mm etc.) as these will factor in the screen density.
If you still have an issue, look at Screens support in the Android Docs, especially Using configuration qualifiers. Examples can be found here.
Basically you would need to provide a different resource file for each screen size. You should have a file something like res/values/dimens.xml where you store sizes for all your components. Make sure your font sizes are declared and referenced from here. You can then create a series of folders/files for the different screen sizes
res/values/dimens.xml
res/values-sw320dp/dimens.xml
res/values-sw720dp/dimens.xml
res/values-sw1024dp/dimens.xml
where each of these folders define the smallest width screen that that file will be used for.

How to make my Gideros game adaptable to all screen sizes?

I am quite new to Gideros and game development as well.
I am trying to build a game, it looked fine with the Gideros player, but when I tried with an Android phone, the background was way too small. I changed its properties to autoscaling so as to fit in with the width. The background now fits in the width, but other objects seem to go to absurd locations.
Though I was using W = application:getDeviceWidth(), H = application:getDeviceHeight(), and while setting up the location, used W/2 and H/2 instead of hardcoding it.
However, this object that seems to shift to rightmost bottom end(in landscape left mode) was right at its center if I do not apply fit width property.
What can I do to fix it?
You should use W = application:getContentWidth() , H = application:getContentHeight() which would return logical dimensions that are used when in scaling mode.
Basically it all brings down to these points:
1) Choose the scaling mode that is proper for your game (Letterbox being most popular)
2) Choose logical dimensions for your game and create all the graphics for logical dimensions you set in the project properties (recommended 480x800 or 640x960)
3) Create backgrounds a little more bigger than logical dimensions to cover whitespaces on devices with different ratios
4) Use absolute positioning (http://appcodingeasy.com/Gideros-Mobile/Ignore-Automatic-Screen-Scaling-when-positioning-objects) for objects that need to stick to sides of the screen as on screen buttons for example
5) (Optionally) prepare bigger graphics in in some fixed ratio coefficient and use Automatic Image Resoltuion feature to automatically load them for bigger devices
More information available here:
http://members.giderosmobile.com/knowledgebase.php?action=displayarticle&id=79
Addition: (Difference between device and logical dimensions)
Device dimensions is exactly what device has. Meaning on an iPhone 3GS it will return width as 320
But logical dimensions are exactly what you set in your project properties. No matter what resolution you have, the logical dimensions will always be the same. They basically will be scaled based on the scale mode you choose.
Here are more specifics on that topic: http://appcodingeasy.com/Gideros-Mobile/Difference-between-content-logical-and-device-dimensions-in-Gideros-Mobile
So if you are developing only for one specific resolution, you can use Device dimensions, otherwise it is suggested to use Logical dimensions with the scale mode you find suitable.

Simple window size in jquery mobile

I am using JQM with HTML5 boiler plate. My objective (for tests purposes) is to have in a desktop browser, an overall div that will show me the expected size areas of my app on a real device. In a desktop browser, however, the width compared to the iphone4 browser width layout do not seems to match. I do not wish to change the viewport meta definition, although I suspect that it is my problem. Can somebody explain to me:
Why the size of a div of size 640 x 960 px (with a border of 1 px and a position of absolute) does not reflect the same size area appearance on the actual device with this type of setup ?
Regards.
Just use Chrome's Developer Tools. You can choose to spoof your User Agent as well as the device metrics for different devices.
When in Chrome:
Press F12.
Click on the gear icon to the bottom right (settings).
Click on the Overrides tab.
Here you can choose to change your User Agent string or override the viewport of your browser to match specific devices (like the iPhone). If you change the User Agent string to mimic an iPhone then the Device Metrics should auto adjust to be the proper size for the same device.
Note that you must keep the Chrome Developer Tools open, as soon as you close them you lose the UA spoofing and Device Metrics spoofing as well.
To directly answer your question, different screens have different pixel densities, so a screen with higher pixel density will show the same number of pixels in a smaller physical area.
As an add-on,
When dealing with CSS Media queries there is a difference between the
device-width and the
width.
For the iphone4, for instance, although the resolution
(width x height) is equal to (640 x 960),
the device is actually presenting
(device-width x device-height) as equal to (320 x 480)
From here we observe that each CSS pixel is handled by 2 screen resolution pixel. This is the consequence of the 2 different size.
This help: Pixel density for different devices

iOS webview scaling to match retina display

I'm using a full screen UIWebView to house/render an HTML5 application under iOS. Very much like Cordova/phonegap although I'm not using those. I try to make my webview size match the underlying display. Unfortunately, on retina displays, the value returned by self.view.bounds relies on the UIScreen scaling factor. So I get 1024x768 instead of 2048x1536. Not a huge problem except I then instantiate the UIWebView using the smaller bounds (after adjusting for the status bar) and some things get a bit jaggy. In particular, I use canvas at a couple of points and also rounded borders appear thick. To be clear, this isn't a case of scaled raster resources.
I'm not getting the full resolution of the screen using that UIWebView. Ideally, I'd like to set the screen scale to 1.0 but that doesn't appear to be supported. Any suggestions on how best to get full advantage of the screen?
The problem is most noticeable on the iPhone 5 simulator. I don't have that hardware to test on. iPad/new iPad I think has the problem but the jaggies aren't as noticeable.
Update: The more I look at this, the more I think it may be restricted to canvas.
Solution: In case anyone else gets here. Based on the answer below, I created all of my canvas elements with width and height multiplied by window.devicePixelRatio and then set their style attribute to have the original (device independent) size.
See https://stackoverflow.com/a/7736803/341994. Basically you need to detect that you've got double resolution and effectively double the resolution of the canvas.

What size image should I use for BlackBerry context menus?

The BB OS 5.0 supports images for context menus. The API documentation says the image will be scaled to fit a square set by the height of the menu font. I find that totally unhelpful.
The only way I can explain that method of calculation is due to screen resolution and DPI. But since the 5.0 OS is only valid on a handful of devices with similar screen sizes, I reckon they can specify the actual icon size they use.
I'd like to choose an icon size that's closest to the default menu font height so that the they look OK.
What size do you use? Do you even use this feature?
I haven't used it yet, but I would recommend using any square ratio maybe up to 64x64; the problem is that with new devices on the horizon (eg rumored tablet - with much bigger display) it won't necessarily be practical to target a specific screen size.

Resources