hi good afternoon any ideas in how can i improve png quality of my icons? i used the kit from android developer page but i cant get sharp images i mean crystal clear, do i need to load this icons in a diff way than just draging into my layout? thanks
i use this layout:
<!-- Rightend Arrow -->
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
for example you can see the right arrow icon in eclipse sharp but in emulator and device looks blurred:
You need to provide resources for all densities. If you just place one icon in res/drawable, that resource will be used and scaled for densities above mdpi. So for an hdpi device, you're going to see an upscaled (150%) version of your drawable, and for xhdpi, you'll see a 200% upscaled version of your graphic.
This is bad.
You'll need to create larger versions of your graphic using the 3:4:6:8 ratio, where mdpi is the density (4). You can mostly ignore ldpi, but just provide a fallback in res/drawable. Your icon for hdpi should be 1.5x larger, and your xhdpi icon should be 2x as large. So for instance, an image you want to display at 48x48dp (device-independent pixels) should be created at 48x48px for mdpi (placed in res/drawable-mdpi), 72x72px for hdpi (placed in res/drawable-hdpi), and 96x96 for xhdpi (placed in `res/drawable-xhdpi). Android will automatically pick the correct version for your density if you've made it available, and won't scale it.
Keep in mind, the graphics still will be only as sharp as you design them originally.
See this article for more information.
I use MobiOne software to author android apps and I ran into the same blurry icon issues when I was following the 36, 48, 72, and 96-pixel icon sizes rule. Guess what? I replaced the 96px one with 300px image and the resulting icon came out crispy and sharp when viewed on Samsung Galaxy S4. I later replaced the 72px one with 200px image.
Related
I'm making an android App that shows images at full screen.
I learned some about dpi and dp, but I didn't find how many pixel must be the largest side of my images (in prospective to good fit also in landscape mode) to appear good in different devices.
As in the documentation, the most used screen configurations are normal with hdpi, xhdpi and xxhdpi density:
So, if my thinking is correct, I can make only one image to fit the xxhdpi to works fine also with the other two densities, and put it in Android Studio under the "res/drawable" folder (without qualifier).
Specifying the image size in dp in the layout, Android should scale the image for the smaller configurations.
But, for the xxhdpi, how many pixel must be the largest side of my image, in pixel, to show good?
Edit: how many pixel must be the longest side of my image to be showed properly in a device with xxhdpi density without the image appearing grainy?
All images are photo, not icons, so I can't use the vector graphics.
By looking at the Android Documentation. One can estimate the size of the picture. look at below picture
So, your image resolution should be in similar resolution
LDPI: 200 X 320px
MDPI: 320 X 480px
HDPI: 480 X 800px
XHDPI: 720 X 1280px
XXHDPI: 960 X 1600px
XXXHDPI: 1440 x 2560px
A little bit of +/- won't affect the outcome because with these standard sizes the aspect ratio of any portrait picture should be respected.
Well, if you put the image which fits the xxxhdpi inside the folder drawable, then it will fit all the screens.
But there is another way to use only one image instead of using multiple images for different resolutions. It's by using svg images which are vector images that will not be affected by zoom in or zoom out.
To use svg you need to follow these instructions:
Make the icon to be icon.svg
In the Android Studio, right click on drawable folder
Choose New -> Vector Asset
Choose Local File (SVG, PSD)
Choose your svg file
Click Next and choose the name
Click Finish
In the app build.gradle add the following inside android block:
vectorDrawables {
useSupportLibrary true
}
In the xml layout file, add the following:
<AppCompatImageView
android:width="wrap_content"
android:height="wrap_content"
app:srcCompat="#drawable/your_svg_file"
/>
Android have ratios defined for a image to set in all different drawables
Android icons require five separate sizes for different screen pixel densities. Icons for lower resolution are created automatically from the baseline.
mdpi: 160 dpi 1×
hdpi: 240 dpi 1.5×
xhdpi: 320 dpi 2×
xxhdpi: 480 dpi 3×
xxxhdpi:640 dpi 4×
Above size is for normal pixel icons. There are fix android size for Action bar, Dialog & Tab icons, Launcher icons & Notification icons
Check this link for more details http://iconhandbook.co.uk/reference/chart/android/
You have to take a look at the current market of smartphones.
Here you can see the screen sizes and resolutions of the most popular devices in the market.
http://screensiz.es/
Order the list in pixel per inch and you will see that top smartphones have resolutions bigger than 500 ppi or another way to see it, much bigger than 72ppi of your images.
If you have enough space to store or mechanism to download images try to test with full quality. If thats too much try to find a compromise. Lower image quality and see the result in high resolution screen.
Note that you didn't posted here the total size of image, in case is bigger than screen size, take a look at total size of image and compress it to fit your needs, maintaining as much as possible the resolution.
Edit: Looking only to size of image in pixels, the current biggest screen in smartphone is 2560 x 1440 pixels, so you wont need any image bigger than this.
If I understand your answer correctly, you are talking about images (pictures of lovely cats and dogs?) and not about icons?
I prefer putting images into the nodpi folder.
nodpi Resources for all densities. These are density-independent
resources. The system does not scale resources tagged with this
qualifier, regardless of the current screen's density.
Afterwards I would create a fullscreen ImageView and let imageView do the scaling if needed
most resources have pointed out that when we using (ldpi, mdpi,hdpi, xhdpi,xxhdpi,xxxhdpi), the android doesn't need to rescale image and we won't have cpu overhead for rescaling image.
but i didn't got that point yet, suppose i have an icon image with all size that already mentioned (36px, 48px, 72px, 96px, 144px and 192px), well, in bellow code you see i use 40dp that it doesn't match any above sizes, so android would rescale the image again, then what is advantage if multiple drawable?
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android: src="#drawable/icon"
/>
You'll often not have an image with an exact Pixel match for the DPs you describe in the layout -- like the case you describe above. When this happens Android will still need to do some scaling.
The benefit isn't CPU savings, its Memory savings.
Scaling operations on large images can require a great deal of memory, especially if scaling from small to large, or large to small.
If you're starting with an image that is close and only need to scale a little, the memory cost is less significant.
If an image is w500px, h500px, that is 250000 pixels. Even if that image is a jpg and compressed to be 10kb on the disk, scaling requires Android to convert to RGB or ARGB which is 3 or 4 bytes per pixel.
4 bytes x 250000 = 1M of memory.
500px on a device that is XXXHDPI is only about 1 inch on the screen.
So you can see how this can add up quickly.
EDIT: This might be useful https://developer.android.com/topic/performance/graphics/load-bitmap.html
Contrary to what Aaron says, the benefit of providing these images is not about system resources, it is about how your app will look to users on different devices. By providing high-resolution copies of the same image, users on high-resolution devices will see crisp, clear images instead of upscaled fuzzy images.
Your question mentions specific pixel dimensions for an image. I assume these values are taken from https://developer.android.com/guide/practices/screens_support.html
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
When you provide all of these different resolutions for your image, you are not providing different physical sizes. Of course 144x144 is three times larger than 48x48, but this 144x144 image will not appear three times larger when the user sees it on their device.
The system will only choose to display the 144x144 image when the user has a device with a high-resolution screen. This means the individual pixels in their display will be smaller, which means the 144x144 image will take up the same physical space as the 48x48 would on a lower-resolution screen.
In short: all of the images in this example are 48dp x 48dp.
Now, if you display this image in an ImageView that is 40dp x 40dp, the image will either be cropped or scaled down. But this has nothing to do with the extra images you've provided. Whether on a very low-resolution screen or a very high-resolution screen, the system will still be stuffing a 48x48 image into a 40x40 container.
Update
Here's an example. I've used Android Studio's New -> Image Asset menu to create an image. You can see that AS generates multiple copies of the same image with different dimensions:
Next, I create two emulators:
Nexus S (hdpi): http://www.gsmarena.com/samsung_google_nexus_s-3620.php
Nexus 5 (xxhdpi): http://www.gsmarena.com/lg_nexus_5-5705.php
And then I run an app that just displays my image on both of them:
You can see that the status bars, action bars, and the little android all appear the same size. But the Nexus S is displaying the hdpi image (48px x 48px) while the Nexus 5 is displaying the xxhdpi image (96px x 96px). Both look sharp!
Finally, I delete all copies of my image except for the mdpi one. Now both emulators use the mdpi image, but you can see that they still display at the same size. The image's intrinsic size is 32dp x 32dp, so even though both emulators are using a 32px x 32px image, both have to scale it up (the Nexus S has to scale it 1.5x and the Nexus 5 has to scale it 3x).
As you can see, the little android is the same size, but it looks much worse. This is why you provide copies of the same image at different resolutions: so that your images always appear crisp!
I was working on android app based on phone. However, recently the app need to support the tablet.
The design was based on 1920 * 1080, I put all images/ icons into the xxhdpi folder and for lower resolution I just let android to help me rescale it.
The problem is , it works well on phone(1280 * 800 5"), but when I use tablet to check it (say , galaxy tab 2 which resolution is only 1280 * 800 10.1" and 1024 * 600) but it looks like very blur . How to fix it ? Thanks for helping.
Added
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:anyDensity="true"/>
already but still the same
Update: I also find that the dp is too small for the tablet
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
<item name="android:actionBarSize">60dp</item>
</style>
I was using a custom actionBarSize , it works nice on phone, but the 60dp is too small for tablet, how can I fix it as well? Thanks
Well, I don't think you following the guidelines when you're using images. The android documentation doesn't say anything about screen resolutions when dealing with images, it rather focuses on pixel density when referring image resources (usually drawables) which is explained here. Remember that you can have two types of images (as far as I know):
Image resources (usually drawables)
Image assets
When using drawables you have to focus on pixel density rather than screen resolution because as you have just found out a small (or regular) screen device can have exactly the same resolution as a large screen device, to top it off, sometimes a normal screen device (handset) can have a higher resolution than a large screen device (tablet) where obviously in this case the handset has a much higher pixel density. So, you need to follow their guidelines take a medium pixel density (mdpi) device as the baseline to design your image resources as follows...taking a 96px image as an example...
for a medium density device (mdpi) provide an image with 96px in the drawable folder...this is your baseline
then, target a high pixel density(hdpi) device by multiplying your baseline image by 1.5...that is, 96x1.5 = 144px...place this image inside the drawable-hdpi folder with exactly the same name
a x-large pixel density device image would be the baseline image multiplied by 2 (96x2=192px). This goes inside the drawable-xhdpi folder
for an xx-large picel density (xxhdpi) device multiply the baseline image by 3 (96x3=288) and place it inside the drawable-xxhdpi folder
Notice in the link provided that you don't need to provide an image for a device with a low pixel density since Android scales it down from mdpi without any problems...
Note: Android also supports low-density (LDPI) screens, but you normally don't need to create custom assets at this size because Android effectively down-scales your HDPI assets by 1/2 to match the expected size.
In your case, whats happening is that your Galaxy tablet has a lower pixel density and Android down-scales the image from a xxhdpi to whatever density the tablet has (hdpi or xhdpi)....so, it your image is a 512px image Android would down-scale it to 341px for xhdpi or 256px for an hdpi device.
If you follow these guidelines and focus on pixel density, you should be fine. However, for images in the assets folder there's no much you can do apart from using the ScaleType enum or using stretchable 9-patch images
Hope this helps
Update
Actually, according to this link, the Galaxy Tab 2 has mdpi screen, which means your image will be scale down three times from xxhdpi. You should provide the same images with different sizes inside the appropriate drawable-x folders
I know its a way too late but recently I faced the same issue about the way app launcher icons looks on a tablet and they are blurry. I'm sure that AOS honestly chooses mdpi drawables for tablets with mdpi display density and thats the problem. So I solved this by placing smartphones icons to a tablet resources dirs as following (left column - usual smartphone drawables-density and the right - tablet dirs):
drawable-xhdpi -> drawable-large-mdpi (these are 96x96px)
drawable-xxhdpi -> drawable-large-hdpi (these are 144x144px)
drawable-xxxhdpi -> drawable-large-xhdpi (these are 192x192px)
drawable-xxxhdpi -> drawable-xlarge (these are 192x192px)
I'm not sure if last two has to be 288x288 px but since I don't have such icons in the project I guess 192x192 should be enough.
I have a full screen PNG I want to display on splash. Only one error there, and I have no idea
what size to put in every drawable folder (ldpi, mdpi, hdpi, and xhdpi). My application is supposed to run good and beautiful on all phones and tablets. What sizes (in pixels) should I create so the splash displays nice on all screens?
Disclaimer
This answer is from 2013 and is seriously outdated. As of Android 3.2 there are now 6 groups of screen density. This answer will be updated as soon as I am able, but with no ETA. Refer to the official documentation for all the densities at the moment (although information on specific pixel sizes is as always hard to find).
Here's the tl/dr version
Create 4 images, one for each screen density:
xlarge (xhdpi): 640x960
large (hdpi): 480x800
medium (mdpi): 320x480
small (ldpi): 240x320
Read 9-patch image introduction in Android Developer Guide
Design images that have areas that can be safely stretched without compromising the end result
With this, Android will select the appropriate file for the device's image density, then it will stretch the image according to the 9-patch standard.
end of tl;dr. Full post ahead
I am answering in respect to the design-related aspect of the question. I am not a developer, so I won't be able to provide code for implementing many of the solutions provided. Alas, my intent is to help designers who are as lost as I was when I helped develop my first Android App.
Fitting all sizes
With Android, companies can develop their mobile phones and tables of almost any size, with almost any resolution they want. Because of that, there is no "right image size" for a splash screen, as there are no fixed screen resolutions. That poses a problem for people that want to implement a splash screen.
Do your users really want to see a splash screen?
(On a side note, splash screens are somewhat discouraged among the usability guys. It is argued that the user already knows what app he tapped on, and branding your image with a splash screen is not necessary, as it only interrupts the user experience with an "ad". It should be used, however, in applications that require some considerable loading when initialized (5s+), including games and such, so that the user is not stuck wondering if the app crashed or not)
Screen density; 4 classes
So, given so many different screen resolutions in the phones on the market, Google implemented some alternatives and nifty solutions that can help. The first thing you have to know is that Android separates ALL screens into 4 distinct screen densities:
Low Density (ldpi ~ 120dpi)
Medium Density (mdpi ~ 160dpi)
High Density (hdpi ~ 240dpi)
Extra-High Density (xhdpi ~ 320dpi)
(These dpi values are approximations, since custom built devices will have varying dpi values)
What you (if you're a designer) need to know from this is that Android basically chooses from 4 images to display, depending on the device. So you basically have to design 4 different images (although more can be developed for different formats such as widescreen, portrait/landscape mode, etc).
With that in mind know this: unless you design a screen for every single resolution that is used in Android, your image will stretch to fit screen size. And unless your image is basically a gradient or blur, you'll get some undesired distortion with the stretching. So you have basically two options: create an image for each screen size/density combination, or create four 9-patch images.
The hardest solution is to design a different splash screen for every single resolution. You can start by following the resolutions in the table at the end of this page (there are more. Example: 960 x 720 is not listed there). And assuming you have some small detail in the image, such as small text, you have to design more than one screen for each resolution. For example, a 480x800 image being displayed in a medium screen might look ok, but on a smaller screen (with higher density/dpi) the logo might become too small, or some text might become unreadable.
9-patch image
The other solution is to create a 9-patch image. It is basically a 1-pixel-transparent-border around your image, and by drawing black pixels in the top and left area of this border you can define which portions of your image will be allowed to stretch. I won't go into the details of how 9-patch images work but, in short, the pixels that align to the markings in the top and left area are the pixels that will be repeated to stretch the image.
A few ground rules
You can make these images in photoshop (or any image editing software that can accurately create transparent pngs).
The 1-pixel border has to be FULL TRANSPARENT.
The 1-pixel transparent border has to be all around your image, not just top and left.
you can only draw black (#000000) pixels in this area.
The top and left borders (which define the image stretching) can only have one dot (1px x 1px), two dots (both 1px x 1px) or ONE continuous line (width x 1px or 1px x height).
If you choose to use 2 dots, the image will be expanded proportionally (so each dot will take turns expanding until the final width/height is achieved)
The 1px border has to be in addition to the intended base file dimensions. So a 100x100 9-patch image has to actually have 102x102 (100x100 +1px on top, bottom, left and right)
9-patch images have to end with *.9.png
So you can place 1 dot on either side of your logo (in the top border), and 1 dot above and below it (on the left border), and these marked rows and columns will be the only pixels to stretch.
Example
Here's a 9-patch image, 102x102px (100x100 final size, for app purposes):
Here's a 200% zoom of the same image:
Notice the 1px marks on top and left saying which rows/columns will expand.
Here's what this image would look like in 100x100 inside the app:
And here's what it would like if expanded to 460x140:
One last thing to consider. These images might look fine on your monitor screen and on most mobiles, but if the device has a very high image density (dpi), the image would look too small. Probably still legible, but on a tablet with 1920x1200 resolution, the image would appear as a very small square in the middle. So what's the solution? Design 4 different 9-patch launcher images, each for a different density set. To ensure that no shrinking will occur, you should design in the lowest common resolution for each density category. Shrinking is undesirable here because 9-patch only accounts for stretching, so in a shrinking process small text and other elements might lose legibility.
Here's a list of the smallest, most common resolutions for each density category:
xlarge (xhdpi): 640x960
large (hdpi): 480x800
medium (mdpi): 320x480
small (ldpi): 240x320
So design four splash screens in the above resolutions, expand the images, putting a 1px transparent border around the canvas, and mark which rows/columns will be stretchable. Keep in mind these images will be used for ANY device in the density category, so your ldpi image (240 x 320) might be stretched to 1024x600 on an extra large tablet with small image density (~120 dpi). So 9-patch is the best solution for the stretching, as long as you don't want a photo or complicated graphics for a splash screen (keep in mind these limitations as you create the design).
Again, the only way for this stretching not to happen is to design one screen each resolution (or one for each resolution-density combination, if you want to avoid images becoming too small/big on high/low density devices), or to tell the image not to stretch and have a background color appear wherever stretching would occur (also remember that a specific color rendered by the Android engine will probably look different from the same specific color rendered by photoshop, because of color profiles).
I hope this made any sense.
PORTRAIT MODE
MDPI is 320x480 dp = 320x480px (1x)
LDPI is 0.75 x MDPI = 240x360px
HDPI is 1.5 x MDPI = 480x720px
XHDPI is 2 x MDPI = 640x960px
XXHDPI is 3 x MDPI = 960x1440px
XXXHDPI is 4 x MDPI = 1280x1920px
LANDSCAPE MODE
MDPI is 480x320 dp = 480x320px (1x)
LDPI is 0.75 x MDPI = 360x240px
HDPI is 1.5 x MDPI = 720x480px
XHDPI is 2 x MDPI = 960x640px
XXHDPI is 3 x MDPI = 1440x960px
XXXHDPI is 4 x MDPI = 1920x1280px
EDIT:
I would suggest to use Lottie for splash screen if you are reading this in 2019+
PORTRAIT
LDPI: 200x320px
MDPI: 320x480px
HDPI: 480x800px
XHDPI: 720px1280px
LANDSCAPE
LDPI: 320x200px
MDPI: 480x320px
HDPI: 800x480px
XHDPI: 1280x720px
I have searched the best and the simplest answer to make 9-patch image. Now to make the 9 patch image is the easiest task.
From https://romannurik.github.io/AndroidAssetStudio/index.html you can make a 9-patch image for all the resolutions - XHDPI,HDPI,MDPI,LDPI in just one click.
Using PNG is not such a good idea. Actually it's costly as far as performance is concerned.
You can use drawable XML files, for example, Facebook's background.
This will help you to smooth and speed up your performance, and for the logo use .9 patch images.
Density buckets
LDPI 120dpi .75x
MDPI 160dpi 1x
HDPI 240dpi 1.5x
XHDPI 320dpi 2x
XXHDPI 480dpi 3x
XXXHDPI 640dpi 4x
px / dp = dpi / 160 dpi
In my case, I used list drawable in style.xml. With layer list drawable, you have just needed one png for all screen size.
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#drawable/flash_screen</item>
<item name="android:windowTranslucentStatus" tools:ignore="NewApi">true</item>
</style>
and flash_screen.xml in drawable folder.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:color/white"></item>
<item>
<bitmap android:src="#drawable/background_noizi" android:gravity="center"></bitmap>
</item>
</layer-list>
"background_noizi" is a png file in the drawable folder.
I hope this helps.
Some time ago i created an excel file with supported dimensions
Hope this will be helpful for somebody
To be honest i lost the idea, but it refers another screen feature as size (not only density)
https://developer.android.com/guide/practices/screens_support.html
Please inform me if there are some mistakes
Link1: dimensions.xlsx
Link2: dimensions.xlsx
Edited solution that will make your SplashScreen look great on all APIs including API21 to API23
If you are only targeting APIs24+ you can simply scale down your vector drawable directly in its xml file like so:
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="640"
android:viewportHeight="640"
android:width="240dp"
android:height="240dp">
<path
android:pathData="M320.96 55.9L477.14 345L161.67 345L320.96 55.9Z"
android:strokeColor="#292929"
android:strokeWidth="24" />
</vector>
in the code above I am rescaling a drawable I drew on a 640x640 canvas to be 240x240. then i just put it in my splash screen drawable like so and it works great:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque"
android:paddingBottom="20dp" android:paddingRight="20dp" android:paddingLeft="20dp" android:paddingTop="20dp">
<!-- The background color, preferably the same as your normal theme -->
<item>
<shape>
<size android:height="120dp" android:width="120dp"/>
<solid android:color="#android:color/white"/>
</shape>
</item>
<!-- Your product logo - 144dp color version of your app icon -->
<item
android:drawable="#drawable/logo_vect"
android:gravity="center">
</item>
</layer-list>
my code is actually only drawing the triangle in the picture at the bottom but here you see what you can achieve with this. Resolution is finally great as opposed to the pixelated edges I was getting when using bitmap. so use a vector drawable by all means (there is a site called vectr that I used to create mine without the hasle of downloading specialized software).
EDIT in order to make it work also on API21-22-23
While the solution above works for devices runing API24+ I got really disappointed after installing my app a device running API22. I noticed that the splashscreen was again trying to fill the entire view and looking like shit. After tearing my eyebrows out for half a day I finally brute-forced a solution by sheer willpower.
you need to create a second file named exactly like the splashscreen xml (lets say splash_screen.xml) and place it into 2 folders called drawable-v22 and drawable-v21 that you will create in the res/ folder (in order to see them you have to change your project view from Android to Project). This serves to tell your phone to redirect to files placed in those folders whenever the relevant device runs an API corresponding to the -vXX suffix in the drawable folder, see this link. place the following code in the Layer-list of the splash_screen.xml file that you create in these folders:
<item>
<shape>
<size android:height="120dp" android:width="120dp"/>
<solid android:color="#android:color/white"/>
</shape>
</item>
<!-- Your product logo - 144dp color version of your app icon -->
<item android:gravity="center">
<bitmap android:gravity="center"
android:src="logo_vect"/>
</item>
For some reason for these APIs you have to wrap your drawable in a bitmap in order to make it work and jet the final result looks the same. The issue is that you have to use the aproach with the aditional drawable folders as the second version of the splash_screen.xml file will lead to your splash screen not being shown at all on devices running APIs higher than 23. You might also have to place the first version of the splash_screen.xml into drawable-v24 as android defaults to the closest drawable-vXX folder it can find for resources. hope this helps
** If you are looking for screen details for all kind of major devices **
go to material.io
Based off this answer from Lucas Cerro I calculated the dimensions using the ratios in the Android docs, using the baseline in the answer. I hope this helps someone else coming to this post!
xxxlarge (xxxhdpi): 1280x1920 (4.0x)
xxlarge (xxhdpi): 960x1440 (3.0x)
xlarge (xhdpi): 640x960 (2.0x)
large (hdpi): 480x800 (1.5x)
medium (mdpi): 320x480 (1.0x baseline)
small (ldpi): 240x320 (0.75x)
I use .png as a background for a custom button that I declare in XML like this
android:background="#drawable/samplepng"
But I can't get the resolution right for tablet screens :
For example, my ressource is a 200x200 pixels .png (initially designed for iOS and retina)
I place a 100x100 px version in the drawable-mdpi folder and a 200x200 px version in the drawable-xhdpi folder.
I also need to have a layout for a typical 320x480 screen in the layout folder and another layout for 10" tablets in the layout-xlarge folder.
The size of the button is 100x100 dp in the normal layout and 200x200 dp for xlarge layout, so that it looks right.
With the Android emulator, a 10" tablet uses mdpi ressources and xlarge layout.
As a result, the button background is drawn with a scaled version of the 100x100 image which looks very blurry, as opposed to the crisp 200x200 original image.
If I don't use a mdpi ressource, it looks blurry just as well.
Am I doing something wrong ? is it only an emulator problem and it looks nice on a real device ?
Please help, I read 10 times google's doc but can't find an answer.
If you don't launch the emulator with 'Scale display to real size' checked, then it will always use mdpi drawables.
See here for more.
Your issue might be in the android version your targeting. Try switching the emulator to android 3.0 and 3.1.