I am having a big trouble in resizing my images for Android image sizes, ldpi (120 dpi), mdpi(160 dpi), hdpi(240dpi), xhdpi(320 dpi) and nodpi using Photoshop, because I don't know how to convert my images to these size. As you know, Photoshop has no DPI stuff to work with. So, what I actually need is to convert my images to ldpi,mdpi,hdpi and xhdpi sizes using Photoshop.
So, how can I convert these images to the Android deserved sizes?
Have you tried using Illustrator? The psd files can also be worked with it.
You could also use Inkscape or other free tools.
Check this: http://envyandroid.com/archives/271/easiest-way-to-create-android-icons
Hope this helps.
The answer is right there in your screenshot. Photoshop uses Pixels/Inch which is the same as DPI (well mostly, anyway).
To achieve what you are trying to do, simply alter the Pixels/Inch in the Image Size dialog to your DPI value - start with 320dpi, since shrinking images will look better than enlarging them. After altering the value you will notice that your width and height values (Pixel Dimensions) are changed, change them back to the desired resolution for your 320dpi image (make sure that you use a sufficiently large resolution for 320dpi).
Now create your image for this resolution. Once you are complete, open the Image Size dialog again. Now all you need to do is alter the Pixels/Inch value to the remaining DPI values (240, 160, 120) and your image will be scaled down (notice how the width and height for Pixel Dimensions will get smaller with each decrease in DPI).
If you have no idea about the starting resolution you can use the width and height under Document Size to set the actual resolution. For example, the Nexus 4 is a 320ppi device (mostly) and has a screen size of 4.7" (5.27x x 2.70x), so if you use a width of 2.635" and a height of 1.35" it should cover 1/4 of it's screen (half of width and half of height).
Related
Basically title. In my layout, my images use a constant size of 200dp x 200dp. So does that mean I shouldn't bother including drawable-hdpi, drawable-xhdpi etc. as long as I use a single 200 px by 200 px image?
200px by 200px is not the same as 200dp * 200dp
Read: https://www.quora.com/What-is-the-difference-between-px-dp-dip-and-sp-in-Android
What i mean by this, is that its impossible that your image is 200dp * 200dp in every screen.
Since dp's size change in every screen, For some screens [160 dpi screens only] 200dp * 200dp is 200px * 200px, but in higher dpi screens this isn't the case, this is why if you only supply a 200px by 200px image it will look perfect in a 160dpi phone screen but in a higher dpi it will look bad (because it will look stretched.) since the higher the dpi the more pixels a dp is.
Here is a pixel to DP calculator so you can check it out for yourself.
https://pixplicity.com/dp-px-converter
That being said if you only supply one xxxhdpi image it should look perfectly fine in every screen but it takes more memory to load that image since it naturally is a higher resolution.
So if you load a xxxhdpi on a mdpi screen it will look worse than the image itself because the resolution for that phone doesn't support it but it will keep the highest quality possible for that screen.
This is why its usually best to have many images for many cases.
Example below of what is 200DP in pixels across different screens, as you can see 200DP can be from 150 pixels to 800px.
Thats why what you're suggesting of having an image in a constant DP size is impossible unless you have an image for each dpi.
Simple answer: NO.
The best way when you have only one picture for all resolutions is to get a better resolution png and you put it in drawable-xhdpi, or even more. By this way, your image will be well displayed.
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
I am using image say 85x85 px (putting this image in drawable-mdpi)
and if i am displaying this image of 85x85 px on [320x480]mdpi screen size device it looks good,
but while displaying this image on [480x800]mdpi device it looks very small.
I wants to know how can i resize this image of (85x85 px) so that it works fine for the device having screen width and height of 480x800, mdpi.
You have to set the image size in the xml in dp. This post is really helpful.
Consider MDPI image(let say 85x85) as baseline Create images as follow
FOLDER ImageSize Percentage
LDPI 64x64 75% of baseline
MDPI 85x85 100% BASELINE
HDPI 127x127 150% of baseline
XHDPI 170x170 200% of baseline
The better solution for this is to produce LDPI,MDPI,HDPI,XHDPI,XXHDPI sized images and place it inside the corresponding folders.
Put the image in /drawable, and define the size of the image in your XML as 85dp, it will then be scaled for LDPI/HDPI/XHDPI/XXHDPI and god forbid XXXHDPI.
However, the better solution would to produce HDPI(128px)/XHDPI(170px)/XXHDPI(255px) version of the graphics and put them in /drawable-hdpi, /drawable-xhdpi, /drawable-xxhdpi respectively. This way you can provide the best experience for your users.
[Edit]
"dp" is Android's way of defining physical size of an UI objects, so a button of 48x48dp will have roughly the same physical dimension even when run on screen sizes between 240x320 to 1080x1920, for more information check Android developer site's Supporting Multiple Screens.
[Edit 2]
For images on canvas you can use this to calculate the scaled size of the image:
DisplayMetrics dm = new DisplayMetrics();
context.getWindowManager().getDefaultDisplay().getMetrics(dm);
int newSize = (int)(85 * (dm.densityDpi / 160f));
I'd like to ask about one of the hardest thing for me (as a programmer) in android. As I make software mostly without designer (to be honest - totally without a designer) I can't figure out the following:
When I draw a png I use px (not dp) as image width.
I drew a button image with the following sizes:
hdpi: 318x45
mdpi: 212x30
(6 to 4 ratio)
and I would like my button be 80% width of Galaxy s2 which is
Screen Size in Pixels: 480 Pixel x 800 Pixel Screen Size in dp: 352dp
x 587dp
But also I would like to have the same width (80%) for hdpi 10' tablet. Is it possible or I'm missing something?
And is it possible to make 80% but not more than XXX pixel width?
You just need to provide different size images for different screen sizes and densities. When you think about it there's only a few different formats you need to worry about. You will then just create an "80%" size image for each of those formats, place them in the seperate drawable folders, and use them accordingly.
The android docs on supporting multiplce screen size and providing alternative resources are actually pretty comprehensive on how to do this.
Otherwise I'm sorry you don't have a designer. My tip - make your icons originally in Adobe Illustrator if you have it that way you can easily scale them to whatever size you need. As vector images they won't lose quality so you can change the size all you want. When you're ready, just export for web and devices at the size break points and you should be fine.
You have to use the android:layout_weight attribute.
Details outlined in a similar question here
I have an android app that I'm trying to add support for different densities, screen sizes, etc. I've developed the app on the simulator with the HVGA support and used all icons from our iphone app which turns out nice since the resolution was at 320x480. Everything looks good now but I'm a bit confused after reading the official android documentation. For layouts I'm going through and ensuring everything is in dp units but when it comes to the images I'm lost. I know that mdpi is 160 but what do I tell my designer for what the hdpi image needs to be? Do we need to increase the height and width and the dpi? Or is it simply enough to leave the dpi as is and increase the height width? For example, if I have an image that's 100 x 100 with 160 dpi, in order to render it identical on an hdpi screen it should now be 150 x 150 with 240 dpi? Assuming if I leave the dpi at 160 it will just be a little blurred? Sorry about silly question but I just want to make sure I'm doing everything right and I'm really a C developer with no graphics experience at all.... No excuse at all but could use some help. I saw some examples where the splash screen for mdpi was 320x480 at 160 dpi but then the hdpi splash screen was at 480 x 800 at 240. Obviously 480 x 1.5 does not equal 800. Furthermore, after looking at the icons in the android sdk, they only scale up the width and height, not the dpi. Probably because they're icons and don't need to be? Lost in photoshop land....
For me as a Graphic Artist of a Mobile Development Company, I made UI's for Android in this dimension:
HDPI : 640px x 960px in 300dpi optimized by 75%
MDPI : 640px x 960px in 300dpi optimized by 50%
LDPI : 640px x 960px in 300dpi optimized by 25%
Take a look at Providing Resources.
There is a section there on "Screen pixel density (dpi)". You are correct that you just scale your width and height for the resources. A 90 pixel image at ldpi becomes a 120 px a mdpi, a 180 at hdpi and a 240 ad xhdpi.
You are also right that the 800 isn't 1.5 x the base 480 height. The reason for that is that these are all approximates based on targets for each density. The phone os lies to the applications running on it about its actual height and width and scales the resources to match the exact dimensions of the handset, since it can vary. This is my understanding.
I recently solved this problem by generating many PNGs of different sizes from a SVG vector image. These are the ratios I used for screen pixel densities and screen sizes:
ldpi:mdpi:hdpi:xhdpi:xxhdpi <-> 3:4:6:8:12
sw320dp:sw360dp:sw480d:sw600dp:sw720dp <-> 8:9:12:15:18
Putting these two together can give a 5 by 5 table of image size ratios that you need in make your image resources look great on most Android devices' screens. Of course, the downside is that many images will be generated, and the size of your APK will grow.
Please see http://aleakymemory.blogspot.com/2013/11/a-different-look-at-managing-android.html for the table of image size ratios.
Everything looks good now but I'm a bit confused after reading the official android documentation.
Which documentation did you read? Here are some to be going on with:
Supporting Multiple Screens
Icon Design