I have a drawable-xhdpi-v11 folder containing a 48x48 icon which is used in my Notification:
Notification notification = new Notification(R.drawable.ic_not_logo, null, now);
I noticed on my Galaxy Nexus running JB, the icon is shrunk to 36x36, making it blurry. Why does the documentation ask for a 48x48 if it wants a 36x36? Am I missing something? Is there a way to make my notification icons pixel perfect?
EDIT:
Here is a related post
Android status bar expects icons of size 25x25dp while guidelines recommend 32x32dp. Who is wrong?
The answers in this post do not explain why it still asks for a 48x48 sized icon and down scales it to 36x36.
You should provide different version of the very same resource.
Follow the guide: android design status bar
My final conclusion is that it is impossible to have pixel perfect Notification Icons. I experimented with providing different sized icons to the drawable-xhdpi-v11 folder and it down-scales all icons provided regardless of their size, leading to a loss in resolution and blurriness of pixel perfect icons. Pretty disappointing.
You should definitely stick to the 24dp value from the guidelines, but you must provide an xxhdpi res (72px) which can then be used by Android to scale to 36px without blur. Same with app icons, some tablets use the xxhdpi res for the homescreen, even though the device is xhdpi.
Related
I was researching a little bit on mipmap to learn more about it. However, I just ended up confusing myself even more.
In this post: Mipmaps vs. drawable folders
The reason they use a different density is that some launchers
actually display the icons larger than they were intended. Because of
this, they use the next size up.
Hence, I got the idea that with larger icons mipmap will use a higher density(scaling up).
But then in this post: Mipmap drawables for icons
However some launchers (shipped with some devices, or available on the
Play Store) use larger icon sizes than the standard 48dp. Launchers
use getDrawableForDensity and scale down if needed, rather than up, so
the icons are high quality. For example on an hdpi tablet the launcher
might load the xhdpi icon.
I concluded that for larger icons, mipmap will scale down the icons to provide higher quality.
And finally in this post:Mipmap drawables for icons by #Sergej:
What Android will do is, it will try to pick up the image from a
higher density bucket instead of scaling it up. This will increase
sharpness (quality) of the image.
Mipmap will use a higher density instead of scaling up for larger icons.
What is really going on? Thanks.
Update:
Also, in the second post Mipmap drawables for icons by #Kazuaki, I don't understand this
Different home screen launcher apps on different devices show app
launcher icons at various resolutions. When app resource optimization
techniques remove resources for unused screen densities, launcher
icons can wind up looking fuzzy because the launcher app has to
upscale a lower-resolution icon for display. To avoid these display
issues, apps should use the mipmap/ resource folders for launcher
icons. The Android system preserves these resources regardless of
density stripping, and ensures that launcher apps can pick icons with
the best resolution for display.
Even if unused screen densities are stripped, why would the launcher app have to switch to a lower resolution? The current resolution(whatever resolution it's using), isn't unused, meaning, it wouldn't be stripped and the launcher icon wouldn't have to switch resolutions.
How does this work? Thanks.
I think your confusion about #Kazuaki quote is the now deleted documentation, replaced by: https://developer.android.com/training/multiscreen/screendensities#mipmap
Like all other bitmap assets, you need to provide density-specific versions of you app icon. However, some app launchers display your app icon as much as 25% larger than what's called for by the device's density bucket.
For example, if a device's density bucket is xxhdpi and the largest app icon you provide is in drawable-xxhdpi, the launcher app scales up this icon, and that makes it appear less crisp. So you should provide an even higher density launcher icon in the mipmap-xxxhdpi directory. Now the launcher can use the xxxhdpi asset instead.
The mipmap directories provide that "do not remove when trying to make a smaller APK".
In my understanding, mipmaping is principally for scaling-down.
In OpenGL, you can set texture filtering modes. One for scaling-down (minification), another for scaling-up (magnification) (cf. An Introduction to Texture Filtering).
Scaling-down (GL_TEXTURE_MIN_FILTER):
GL_NEAREST
GL_LINEAR
GL_NEAREST_MIPMAP_NEAREST
GL_NEAREST_MIPMAP_LINEAR
GL_LINEAR_MIPMAP_NEAREST
GL_LINEAR_MIPMAP_LINEAR
Scaling-up (GL_TEXTURE_MAG_FILTER):
GL_NEAREST
GL_LINEAR
You notice that there are no options of mipmap for scaling-up, but those are for scaling-down.
So, in my understanding, if scaling-up/down is needed, the nearest higher density texture is chosen to scale-down. Only when the current magnification is higher than the highest density texture, scaling-up is done based on the highest one.
I am using the onCreateOptionsMenu method to create a toolbar with icons in the MainActivity of my app. I am testing on different screen sizes and pixel densities with Android Studio's emulator. The documentation states, "Based on the density of the current screen, the system uses any density-specific resources from your app. If resources are not available in the correct density, the system loads the default resources and scales them up or down as needed." I've tried putting all of my vector icons the default drawable directory, but the system does not scale them for different screen sizes or densities at all. Nor does onCreateOptionsMenu scale the height of the toolbar or the title text. Is it supposed to? Because of this, I have also tried using different density buckets to address that problem. However, I'm running into an issue with greatly varying screen sizes sharing the same density bucket.
As an example, I'm testing on Pixel 3 (5.5" phone) and Pixel C (10" tablet). They are using the same density bucket (xhdpi) so if I use a 24dp x 24dp icon for the phone, then it looks way too small on the tablet. How do I work around this?
You can string together multiple qualifiers and create a custom bucket. So in addition to the drawable-xhdpi bucket I added a drawable-sw720dp-xhdpi bucket with larger icons for the 10" tablet. Now tablet displays the slightly larger icons while the phone still uses the standard bucket. The solution can be found in the comments of the selected answer in this post by #Theo. Unfortunately the documentation does not state that multiple qualifiers are supported.
I offer the ability to change the app icon via a setting... I'm thinking about adding app icons in all material colors (500 + 900 values) which results in 34 icons + 2 for black and white.
Now I'm thinking of adding them only in a few resolutions instead of all. Which one can I safely remove?
I would add:
mdpi
hdpi
xhdpi
xxhdpi
xxxhdpi
Would it work if I only add xxxhpi icons? Or xxxhdpi + hdpi? Which sizes are necessary so that it always works?
EDIT
Why do I want to do this? Just to keep my app as small as possible but having nice icons for all devices
its best to have images in all size of same name,it will take the image based on the resolution of the device
What is the correct size to choose for Vector Drawable icons e.g. when importing them from SVG?
There is a lot of information about standard icon dimensions for raster icons, for example this site. However, I'm a little bit struggling to get icons imported from SVG appear normally, I'm basically determining them by trial and error.
Particularly interested in launcher and notification icon sizes. I've currently settled on 192x192 for launcher icons and 48x48 for notification icons.
Using a smaller size for launcher icons results in a blurred icon on my KitKat tablet and using a larger size looks bad as well.
But the notification icon still appears larger than in other apps so it should probably be something like 32x32.
You choose what is the best, what it depends on is the version of Android, the default is 24x24 dp
I've created a menu icon and included a 36x36, 48x48 and 72x72 in the ldpi, mdpi and hdpi drawable folders. It looks fine on all devices except honeycomb tablets, where it seems like the padding around the Android icons are bigger than on my custom icon. I've included a screenshot (see how much bigger my 'Resume Reading' icon is than the android 'Back' and 'My Library' icons are). How do I make my icon look like this?
I think I found the problem. When using the Android resource icon's on a tablet, I think it changes the padding in order for the icon to be used in the action bar. So when displaying them in a pop up menu at the bottom they are appearing much smaller than they should be. The solution is to copy the android resources into our own resource folder as it says to do here http://developer.android.com/guide/practices/ui_guidelines/icon_design_menu.html
Most of your Tablets are not hdpi, they are xhdpi. While the Icon Design Guidelines are useful, they don't give the whole story. Consider reading Supporting Multiple Screens. Here, they tell you further ratios and dimensions. To save you some time, resources should be 3ldpi:4mdpi:6hdpi:8xhdpi meaning that your xhdpi icon should be 96 x 96. Please, read the whole document, though. It is insanely useful.