How to provide different resolutions for header image? - android

This is a follow up question to this post. I have a header image on one of my screens and want to scale it to the full width but keeping the aspect ratio. So it should do something like this:
I can do that, but now I have the problem that the image scales relatively bad. (Imagine some text on the picture above, this is not the best example). How can I provide several pictures in different resolutions to android so that android take the pictures which is best for the current screen size/density situation?

Android support different screen densities through the use of configuration qualifier as follow:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
The best practice is to create a directory under the res/drawables/ directory with those qualifier. Eg.: /res/drawable/hpdi and store an image of the appropriate resolution in that folder. Do the same for the other qualifier; the proper image resolution will be chosen automatically based on the screen density of the device. Image filename must be the same in each of the configuration qualifier directory.
More info: Android Developers documentation.

Related

Screen densities and sizes on android (Diff between large/x-large.. // hdpi, xhdpi...)

I've read so much about these things already, so many threads, but there still some things that I don't understand about how to, as a both developer and a designer, avoid problems with different sized screens.
So my question is mainly: What is the difference between putting drawables into mdpi,hdpi,xhdpi,xxhdpi folders as opposed to normal,large,xlarge folders? Should I do both?
I want drawables to act like this: If it takes 50% of the width of the screen on a smartphone, it should take 50% of the screen on a tablet. That's where I'm also confused - Both my phone and tablet are 1920x1080 and both fall into the xhdpi bucket (I believe), but their physical screen sizes are very much different.
Now I save drawables according to the mdpi, hdpi... ratios. Therefore I get results like this on the phone:
When I just out of curiosity created folders for drawables large and xlarge (I didn't know the ratios), I get this, which is closer to what I'm aiming for (but is obviously too big):
But what's the point of using the xhdpi (etc) buckets? Am I understanding this completely wrong? Someone please enlighten me. I hope this question makes sense. My point is - I want the scales of text and pictures to fill about as much of the screen on a tablet as on a smartphone.
Thanks
We developers just create drawbles for mdpi, hdpi, xhdpi, xxhdpi because screen resolution of devices maybe different. While in the case of the normal, large, xlarge folders it is used for the case of screen sizes.We Use This configuration qualifiers (mdpi, hdpi, xhdpi, xxhdpi) because for example for low budget phone, resolution maybe less and will show 48px drawable bigger while high end devices will show it smaller. That's why we create drawables for different resolutions of phones varying from 42(maybe) to 192 px.Similarly normal,large,xlarge folders are used in respect with screen size.
If you want to compress app size, you may use vector drawables. They are just created for one time and look consistent on every time.For Custom icons, export it to .svg or .psd format and create it as vector drawable through android studio.
Edit : I usually create my logo on Photoshop and android studio efficiently exports it to vector drawable.
xlarge screens are at least 960dp x 720dp.
large screens are at least 640dp x 480dp.
normal screens are at least 470dp x 320dp.
small screens are at least 426dp x 320dp.
Vector drawables are put in drawables folder. There is one more advantage of using vector drawables that is one May animate it.
Note : Beginning with Android 3.2 (API level 13), these size groups small, normal, large,xlarge folders are deprecated in favor of a new technique for managing screen sizes based on the available screen width. If you're developing for Android 3.2 and greater use mdpi,hdpi,xhdpi,xxhdpi folders.
The configuration qualifiers (described in detail below) that you can use for density-specific resources are ldpi (low), mdpi (medium), hdpi (high), xhdpi extra-high), xxhdpi (extra-extra-high), and xxxhdpi (extra-extra-extra-high).
Screen Density of devices
A set of six generalized densities:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
Images Sizes as per folders.
36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
144x144 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density. Hope this will help.You ask me more about this in detail in comments.

Access res files from Qt for Android

How can I set for example ToolButton's icon to be "ic_not_interested_black_48dp.png"
I have android/res directory in my Qt project, there are some directories for different screen sizes, drawable-hdpi, drawable-ldpi etc.
What is the best approach to set the correct icon for a given screen.
Does Qt/Android resolve this on its own or do I have to create function that returns me correct prefix 'drawable-hdpi/' or 'drawable-ldpi/' based on my screen size?
While the high DPI support has been substantially improved in Qt 5.6, the support for varying icon density is not yet there.
What you might be able to do though, is use QFileSelector. Upon startup, check the DPI of the device's display with QScreen (e.g. devicePixelRatio), and then map that value to drawable-ldpi, drawable-hdpi, etc. Once you have the correct string, add it to the list of selectors by calling setExtraSelectors(). That way, assuming you have a directory structure like the one below, the correct icon file will be chosen:
drawable-ldpi/
ic_not_interested_black.png
drawable-hdpi/
ic_not_interested_black.png
You'll then need to define a Q_INVOKABLE function in a QObject-derived class and then expose it to QML (e.g. via a context property) that takes a path to an icon file and calls QFileSelector::select(iconPath). When you're done, your usage of it in QML will look something like this:
ToolButton {
iconSource: iconSelector.select("ic_not_interested_black.png")
}
yes you have to create different size and resolution icons drawable-hdpi means high density drawable-ldpi means its low density
There are A set of six generalized densities:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
for details it will help you to load your app in high level to low level devices without performance loss.

What dp should I use for Android icons?

I found this LINK that outlines what dimensions of images/icons/notifications/etc in Android should be. I then looked for some solid standard icons and stumbled upon Google's REPOSITORY. Each icon exists in 18, 24, 36, and 48dp. I can then download each image for mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi.
Why do they offer the 4 different dp's if for each of the dp's I get the icon for all 6 folders (mdpi, hdpi, etc)? Also, which dp is the best? Should I use 48 simply because it's the most crisp?
Size which you pick from this is image size. Each folder inside, is that image, with that size, scaled to proper resolution for each device type screen size (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi).
Which size you will use, it's your choice (or Material Design, if you decide to follow these rules).
The key here is to support multiple screens and different densities.
Almost every application should have alternative drawable resources for different screen densities, because almost every application has a launcher icon and that icon should look good on all screen densities. Likewise, if you include other bitmap drawables in your application (such as for menu icons or other graphics in your application), you should provide alternative versions or each one, for different densities.
To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six generalized densities.
A set of six generalized densities:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
For more information, please refer to the developer site.
18dp is for small contextual icons
24dp is for notification icons
36dp is for action bar, dialog & tab icons
48dp is for launcher icons

Android layout design for small,medium and big screens

My app is almost done , but the problem is that it's layout has been designed only for small screens by now
and
I want to make it for other sizes ,too
I mean to use drawables with higher resolutions in bigger screens
how should I manage it?
You can use this tool Android Asset Studio to generate drawables for different screens.This tool provides many things like drawables for ActionBar, Launcher, Tabs icons etc.
http://romannurik.github.io/AndroidAssetStudio/
You can make different size of images and put them in their respected folder to support multiple screens in android.
If you are using eclipse you can see different types of folders in your drawable which support different screens:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
these are respectively used for high, very high and low screen images. You can get more info at:
http://developer.android.com/guide/practices/screens_support.html
Here is some documentation for that: http://developer.android.com/guide/practices/screens_support.html
For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:
36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
180x180 (3.0x) for extra-extra-high-density
Also I recommend "Asset resizer" app for mac, is really useful for get all the sizes from each image.

Mobile Design: Should I be using double resolution images?

The Galaxy S5 has a display resolution of 1920 x 1080, an iphone is 1334 x 750, and many others are similar. Do these resolutions work the same way that Apple's retina screens work, where images will look blurry unless they have an #2x size version?
Basically, if I am creating a mobile landing page for an add, and I use an image that is 300px wide in the browser, will that image look sharp like it does in the browser or do I need to do something else to make sure it looks good on mobile devices?
If you're talking about photos or photo-like images, Android resizes those fairly well and does a fair job of avoiding unpleasant image artifacts because it uses very accurate rescaling methods.
Anything you expect to be "pixel-perfect" like a 2px-wide line in the image is simply always to be somewhat blurry in a resized result. For those types of images, you'd want to generate different resolution versions of the images in the drawables-* (or mipmap-*) folders and keep in mind the relationship between screen density and pixels.
MDPI is 1:1
HDPI is 1.5:1
XHDPI is 2:1
XXHDPI is 3:1
XXXHDPI is 4:1 (and something you're unlikely to find right now)
...so if you wanted a 1px border in an image that's to be displayed on an XXHDPI screen, in the drawable file that line would need to be 3px wide. The good news is that since these downscale and upscale quite accurately, under most circumstances, an image from drawables-xxhdpi will retain a perfectly clean edge when downsized to all the others (except HDPI, because 1.5) and an image from drawables-mdpi will upscale decently as well. Android will do the best it can at picking an appropriate image to upscale/downscale from the drawables/mipmaps folders when some are missing (i.e., you might not need to populate all of them).
Android's support for higher resolution screens is based on screen density.
A set of six generalized densities:
- ldpi (low) ~120dpi
- mdpi (medium) ~160dpi
- hdpi (high) ~240dpi
- xhdpi (extra-high) ~320dpi
- xxhdpi (extra-extra-high) ~480dpi
- xxxhdpi (extra-extra-extra-high) ~640dpi
http://developer.android.com/guide/practices/screens_support.html
You need to create additional drawable folders and place your higher resolution images there. drawables-hdpi, drawables-xhdpi, drawables-xxhdpi, etc...
There are some tools that will help you resize images to the various densities too. Like this one: https://github.com/redwarp/9-Patch-Resizer

Categories

Resources