So I need to create images to be part of my app that I'm making. I haven't found the answer anywhere.
What I am wondering is...
If I created an image that is to be displayed on Activity1, then what image size in PIXELS should I created the initial image at?
The initial image would then be resized to their corresponding DPI to work well on Android phones.
I may be doing this wrong in creating images so they don't lose their quality, any ideas?
If I am doing this wrong, then please can someone advise on the best practice on creating Android images in pixels and then converting to DPI later after the initial image?
Thank you! :)
EDIT: This question is different because I'm mainly talking about keeping image quality by making the image big first and then downsizing.
You have to create six generalized size image 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 detail check out this link
To generate image for Android device you can follow this as I do:
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. 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
144x144 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density (launcher icon
only; see note above)
Or,
Image resolution and DPI are tightly coupled each other. There is a 3:4:6:8 scaling ratio in drawable size by DPI.
LDPI - 0.75x
MDPI - Original size
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
For example if a 100x100 image is a baseline (MDPI),
LDPI - 75x75
HDPI - 150x150
XHDPI - 200x200
XXHDPI - 300x300
XXXHDPI - 400x400
and so on.
Related
I have 3 images with the following sizes in pixels (I got them from Get Info)
300x200
150x100
600x400
Question: How do I know in which resources directory (hdpi|mdpi|xhdpi etc) I should put them?
There are 8 folders available, and each one varies depending on pixel density:
1. lpdi - Resources for low-density (ldpi) screens (~120dpi).
2. mdpi - Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
3. hdpi - Resources for high-density (hdpi) screens (~240dpi).
4. xhdpi - Resources for extra-high-density (xhdpi) screens (~320dpi).
5. xxhdpi - Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
6. xxxhdpi - Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi).
7. nohdpi - 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.
8. tvdpi - Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six primary densities. 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 (ldpi)
48x48 (1.0x baseline) for medium-density (mdpi)
72x72 (1.5x) for high-density (hdpi)
96x96 (2.0x) for extra-high-density (xhdpi)
144x144 (3.0x) for extra-extra-high-density (xxhdpi)
192x192 (4.0x) for extra-extra-extra-high-density (xxxhdpi)
You can have even more information from Android official documentation
Copy image and paste to drawable folder.
You can add image by using .xml file
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/image_name" />
I am trying to create a splash screen image that scales well for each screen size.
I am trying to determine if I am misunderstanding how pixel densities function.
According to the documentation,
To create alternative bitmap drawables for different densities, you
should follow the 3:4:6:8:12:16 scaling ratio between the six primary
densities. 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 (ldpi)
48x48 (1.0x baseline) for medium-density (mdpi)
72x72 (1.5x) for high-density (hdpi)
96x96 (2.0x) for extra-high-density (xhdpi)
144x144 (3.0x) for extra-extra-high-density (xxhdpi)
192x192 (4.0x) for extra-extra-extra-high-density (xxxhdpi)
Now, I take this to mean that a 192x192 image will occupy the same amount of screen space on an xxxhdpi display as a 48x48 pixel image on a standard display.
That means that if I want a full screen image for a Google Pixel 2 display which is 1080px by 1920px and has an xxhdpi density of 2.6 then I need an image that is 1080 * 2.6 = 2808px by 1920 * 2.6 = 4992px.
Is this logic correct?
I have uploaded an image which is on 3000 by 3000 pixel onto Android Studios.
When I try to add the image to my application, the image does not look sharp.
Here is my XML code
<ImageView
android:layout_width="match_parent"
android:layout_height="200dip"
android:scaleType="fitCenter"
android:contentDescription=""
android:layout_marginTop="20dip"
android:layout_marginBottom="28dip"
android:src="#mipmap/login_logo" />
I believe that my image should be big enough for the image view. Can anyone advise me on how to increase the resolution of my image?
Updated
When I uploaded the image, the 4 different versions of the image were created automatically in the system
The problem is that you are creating an icon set, wich actually does not have 3000 by 3000 pixel. Check it.
The application is using the more appropiate size (hdpi, xhdpi, etc). But you are resizing manually. That's why the icon is not sharp in the screen.
When you create a manual Image Asset, this is the real size depending on screen size. The assistan takes the original image and resizze it.
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
In pixels:
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
You can solve it, creating your custom image asset following this instructions:
LDPI - 0.75x
MDPI - Original size you want to show
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
https://developer.android.com/guide/practices/screens_support.html
Or you can use an external library, like Picasso, to load the original image and fit it. The result will be more professional as far as you can dynamically fit, use placeholders, errorimage, etc.
https://www.google.es/?ion=1&espv=2#q=picasso%20android
Picasso.with(getActivity())
.load(new File("path-to-file/file.png"))
.into(imageView);
I suggest a method which use in onCreate() function. It used BitmapFactory to load your image
Options options = new BitmapFactory.Options();
options.inScaled = false;
Bitmap source = BitmapFactory.decodeResource(a.getResources(), path, options);
ImageView mImg;
mImg = (ImageView) findViewById(R.id.imageView);
mImg.setImageBitmap(source);
Android Export
XXHDPI - 100% baseLine
XHDPI - ?
HDPI - ?
MDPI - ?
LDPI - ?
Plz say anyonce of these sizes
I'm not sure, but don't you need the resolutions of the images?
If so, may I link you to Android Developer support?
You can get a lot of information here:
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
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. 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
192x192 (4.0x) for extra-extra-extra-high-density (launcher icon
only; see note above)
Image example:
Now, lets post this, and calculate the rest!
Edit:
I made a simple calculation with Excel
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.