I used the 9330 simulator for developing my app, and now once I put it on a blackberry bold, I've noticed that my text and images appear much smaller on the device than the simulator. Is there anyway to fix this without having to change every objects height and width? Maybe I need to use Display.getHeight() and .getWidth() more instead of hardcoding numbers?
One way I dealt with this is making the size of my elements variable. I did this by, upon loading the app, detecting the screen size and applying a multiplier that modifies my elements by a given %, the % depends on the screen size. I calculated these percentages by taking a base screen size and seeing how much the screen sized varied from one model to another, there are only 4 screen sizes I believe.
Yes, you shouldn't hardcode any number as bold and curve have differnt screen resolutions
Curve: 8800s, 8300s, 8500s, 9300s 320x240
Bold: 8900s, 9000s, 9600s, 9700s 480x360, 480x320 (Bold 9000)
You will have to change every place you used that numbers and change to gethHeight and getWidth() where needed
For the images you should scale the object, something like this:
Bitmap bitmap = new Bitmap(width, height);
yourBitmap.scaleInto(bitmap, Bitmap.FILTER_BILINEAR);
For texts you should use something like this:
LabelField field = new LabelField("TEST");
field.setFont(field.getFont().derive(Font.PLAIN, yourFontSize));
Related
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
?
I am writing an iPad app which requires letters to be displayed at their exact point size regardless of screen size.
I've implemented the text display using a UILabel object. I have the Autoshrink property set to Fixed Font Size, however the letters on the screen are much smaller than indicated by the font metrics. For instance the capitals of a 251 point font, which should be 3.5 inches tall, are only 2 inches on the screen. At different point sizes the same shrinkage happens.
The fontCapHeight is the same as the font size with the font I am using.
How can I make the displayed size is the same as the font size?
For instance the capitals of a 251 point font, which should be 3.5 inches tall, are only 2 inches on the screen.
You're assuming a point is 1/72", which is not true. That's a desktop publishing point. A point in iOS is a certain number of pixels (based on the scale). The number of pixels in an inch are a factor of the screen's pixel density (PPI). iOS provides no way to query for that that I'm aware of. You have to just have a big table that knows. A fairly nice one for that is GBDeviceInfo, but ultimately it just has a big table of values based on looking up specs or measuring screens.
You need your cap height (pt) to be (ppi/scale)*inches, but you can't set cap height directly. You need to set it via the em box size (the "font size"). Here's an example. It takes a label containing a font of any size and make it's cap height be 3".
let font = label.font!
let ppi = 326.0 // iPhone 6s
let scale = Double(UIScreen.main.scale)
let desiredSize = 3.0 // inches
let emBoxRatio = Double(font.pointSize / font.capHeight)
let fontSize = (ppi / scale) * desiredSize * emBoxRatio
label.font = label.font.withSize(CGFloat(fontSize))
Keep in mind that "make its cap height be 3 inches" is not the same thing as "make any particular letter be 3 inches." It depends on the font and the letter. In many fonts, glyphs with a curved top are a little taller than the cap height, and some ascenders may be a little taller than the cap height. While H, X, and I are often exactly the cap height, sometimes they're a little shorter (sometimes O is the cap height rather than X). Sometimes glyphs are above their baseline. There is nothing that says that a font even has to fit within its em box, and some fonts draw wildly outside (Zapfino, I'm looking at you).
My only point here is that you need to check your actual font carefully. Font metrics are serving suggestions at best. They're meant to make fonts with similar metrics "feel" the same. They're not always absolute measures of things.
I don't understand this:
The fontCapHeight is the same as the font size with the font I am using
If the cap height is the same as the "font size" (em box height), then where are the descenders? It feels like you've run out of em box.
Problem solved. I found the following statement at http://blog.fluidui.com/designing-for-mobile-101-pixels-points-and-resolutions/ : "An iOS point is equivalent to 1/163 of an inch. This size is always the same regardless of the resolution of the phone it is on, and comes from the 163DPI of the original iPhone." I couldn't find it anywhere in the Apple documentation, but I'm sure it is there somewhere!
I have just started learning IOS Development so my knowledge to it is very little.
I am building my layout for my app. I need my app to run on all devices . I have read somewhere that you should never use a constant magic number when creating constraints and always use standard values. I want to support my app for all resolutions
whenever I set standard value it's '0' so does this means that I have to play with multiplier values to have similar spacing
And kindly let me know when we can use constant value and when we have to avoid.
Most of the times you need to space the views evenly in the screen . This makes the view look similar on all devices (like on a bigger screen it should be equivalent to scaled version of how it looks on a smaller screen).
For Eg. If you need to space 3 views horizontally and equally on a view. If you set the height/width of the buttons to a magic number, say 100 pixels. The 3 subviews would look relatively smaller on a iPhone6+ screen than say on a iPhone5 screen.
This is when you use multipliers. Like height/width of buttons = 0.2 of superview.
On the other hand you need to use magic numbers in some cases.
For Eg. You are creating a canvas on the screen in which the user will draw with a menu panel on the left. You know the menu panel fits in say a 50 pixel strip on the left. So if you set the size of the menu panel by a multiplier, then the menu panel will become larger on bigger screens. This would somewhat nullify the advantage of having a bigger screen to draw.
This is when you use magic numbers as you know the menu panel needed to be no larger than 50 pixels.
(Note: never use magic numbers directly. Create constants like k_menu_bar_height = 50. Then use this constant wherever you need. This is much more readable and helps in the long run from a maintenance point of view)
I am working on a BlackBerry App that has a lot of ImageButtons, LabelFields and MessageBoxes. What appears to be perfect on one screen size, seems a mess on the other. For instance, Vertical Field Managers that are neatly aligned center with LabelFields, are left/right aligned on bigger screens. Images that cover the width of the screen appear too small on larger screens. Is there some mechanism to auto-align and dynamically change images with respect to the screen size. Any ideas and documents that can help in this regard?
Here are some tips for making screens that look good on almost all devices:
Use less images. If you have to use images, use atleast 3-4 for different screen sizes. for example if you need to have an image as the screen header, use images with widths 320px, 480px and 640px. Load image depending on the width of the screen.
Do not use pixel measurements. Use point measurements instead. Most of the devices are similar in terms of physical size, whereas they have huge difference in pixel density. Using this you can have a screen which will look exactly identical on curve (320x240), bold2 (480x360) and bold 4 (640x480). If you notice, they have the same aspect ratio and similar physical size.
Do not hardcode positions. Instead use FIELD_HCENTER and DRAW_HCENTER etc for fields.
Do not use fonts with fixed pixel height. Use fixed point height instead.
If using custom fields, make sure that they can automatically expand according to device and pixel density.
I displays a splash Screen when my app loads,There is a background image in the splash screen,I problem is how can I make fit this image in all types of blackberry models?
Keep in mind that many BlackBerry devices have different screen resolutions and even different aspect ratios. So if you just use a single image and resize (stretch and/or squish) it to fit the current screen, you're going to distort the image (or pattern). As I see it, there are two main approaches:
1) Use a different image for each screen resolution. There are about 7 different resolutions that cover most of the in-market devices (240x260, 240x320, 320x240, 360x400, 360x480, 480x320, 480x360)
2) If it's a regular background pattern as opposed to a picture or logo, just have one image in the app that's big enough to cover the largest screen size (480x360) and for all other screen sizes just clip it. In fact, I think this should happen automatically if you just set the background image - anything that can't be displayed on the screen will be clipped.
While approach #2 is better in terms of reducing application size, I'm going to guess that since you're asking this question the background you're thinking of using isn't a regular pattern.
I think the simplest method would be to use the setBorder method of whatever screen/field needs a stretched background. For example:
Border b = BorderFactory.createBitmapBorder (new XYEdges (), bitmap);
field.setBorder(b);
In my experience this results in the background image being stretched and provides the simplest method for fitting the size you need. I have only ever used it for fields though and never a MainScreen so it might not work for you.