I am creating some background images that will cover the "entire" screen of the phone/tablet screen for my app. These images are for the Splash Screen. Basically, my application must support to Phones and Tablets.
I created a huge image which is 2560 x 1600, now time to resize it. But the case is, I am stuck here. What are the screen sizes for mdpi, hdpi, xhdpi, xxhdpi ? These are the screen sizes from phone to tablet right? I need these sizes in pixel values.
I have already visited to the android developer links like supporting multiple screens, but I did not find anything good from them.
Please help me to resize my images by providing the correct screen values in pixels.
Hdpi, xhdpi, etc. are not screen sizes, they are screen pixel densities. If you want to adjust your image according to screen sizes, you should use small/medium/large/xlarge. (And combine it with hdpi/xhdpi/... for sharp and accurate results :))
You can always use some most common resolutions, like HD, fullHD, 800x480 etc. But you have a bigger problem - differences in aspect ratio. Newer devices tend to use 16:9 aspect ratio, but older models with 800x480 screens are different, so you should consider some padding/cropping to ensure image is not stretched, and just then worry about resolution.
Good luck with that :)
Edit:
You can create your own resource folders, you can even use multiple modifiers.
http://developer.android.com/guide/topics/resources/localization.html
Just create folder 'drawable-small-hdpi' or whatever and it will work :)
You can also use other modifiers, f.e. drawable-de-small should load specified drawables only on "german speaking" devices with small displays.
About image sizes: documentation(the article you are linking) states:
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
So you if you want good compatibility, you go like this(in pixels):
small-mdpi = 426x320
small-hdpi = 639x480
small-xhdpi = 852x640
normal-mdpi = 470x320
normal-hdpi = ....
......
xlarge-hpdi = ....
xlarge-xhdpi = 1920x1440
Just remember that 1 dp in mdpi is 1px, in hdpi it is 1.5px, xhdpi is 2px and xxhdpi is 3px.
In practice, you really don't see many xxhdpi devices with small or even normal screen, so you can omit some extremes. If you don't care about some stretching here and there on smaller phones, you can even completely ommit the small option and rely on the match_parent attribute to fit the image.
But you still have to design carefully because these are just minimum sizes.
Also consider phones with hardware buttons and software buttons - with hardware buttons and same screen, you get more space for your app, so, again, different aspect ratio!
From my experience, I would recommend splitting your splash screen in elements that must at all times remail "good looking", like logo. And then define some background that can stretch a bit here and there. So that you can set the background to match_parent and always cover whole screen and "logos" to wrap_content or fixed size in dp so their aspect ratio won't change and pixel size can be easily calculated.
Related
I understand there is plenty of documentation about designing for multiple screen support in Android. and I have read the Android guide here as well as a number of similar questions such as this
However I'm still a little confused as to how I should implement it for my application. I plan to target the following device configurations
Am I correct in thinking I will need to structure the project layouts as follows:
Medium density Normal screens HVGA 320x480 (160dpi):
res/layout-mdpi (320 x 480 )
res/layout-land-mdpi (480 x 320 )
High density Normal screens WVGA800 480x800 (x854) (240 dpi)
res/layout-hdpi (480 x 800)
res/layout-land-hdpi (800 x 480)
But what about the Medium density, large screen devices?
I plan to use sets of both high and medium density drawables too. My primary concern at this early stage is using suitable background images for each layout. For example, to support both the 480x800 and 480x854 sizes, I plan to simply use an ImageView as the background such as:
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/bg"
android:scaleType="center"/>
The 'bg' drawable will always be 480x854 and by using:
android:scaleType="center"
I'm hoping this will take care of those two screen sizes. Whereby the image keeps its original appearance but is centred on the 480x800 screens. I will lose some pixels off the image but as long as the image isn't scaled then that suits my needs.
I plan to have a set of 320x480 assets for the normal screens.
I'm just hoping I'm following the correct procedure here so I appreciate any info/tips from you guys. Thanks in advance
In my experience you don't really need to customize your layout for the small/medium/large/etc screens, as long as you have your drawables for the different densities. Like the documentation says, Android will attempt to render your layout properly on different screen sizes.
By default, Android resizes your application layout to fit the current device screen. In most cases, this works fine. In other cases, your UI might not look as good and might need adjustments for different screen sizes.
The 'other cases' applies only if you really want to change your layout on larger screens.
Using android:scaleType="center" works for me, but it will, like you said, leave empty space around your layout on larger screens if it should fit on smaller screens as well. If you have a fully customized view with 'widgets' that should be placed exactly right, and you don't want to be programmatically determining the scaling and applying the same scaling to your widgets, this is definitely the way to go.
I am having trouble managing my application layouts in three different resolutions; 720x1280, 1080x1920 and 1440x2560.
In drawable-xhdpi folder is the corresponding images to 720x1280 resolution.
The folder drawable-xxhdpi is the corresponding images to 1080x1920 resolution and in drawable-xxxhdpi to 1440x2560.
I began to adjust the screens in layout folders. The layout-sw360dp was setting screens for 720x1280 and the layout-sw480dp the 1080x1920.
When testing in the emulator 720x1280 all settings worked perfectly.
But to test the emulator 1080x1920, oddly taking this information in layout-sw360dp folder and not the layout-sw480dp.
In the case of adjusting each folder layout-sw360dp and layout-sw480dp, I'm using margin with values in 'dp' and emulator higher values (layout-sw480dp) are being dropped are being used and the values of the layout-sw360dp.
How can I manage three screen sizes correctly?
Well designed Android applications cater for varying screen sizes, the screen size being a function of both resolution and density. Using several layout-sw###dp folders allows you to vary the layout according to the width of the display, e.g. showing fewer elements and controls on a small screen and perhaps more detail on a large one.
The 'sw' in the layout folder name is the 'shortest width' a display must have in device independent pixels (dip). One dip = 1 real pixel on a 160 density screen. So on a 320 density screen, 2 real pixels make up one dip.
Your nexus 5 has 480/160 = 3 real pixels per dip. So with a width resolution of 1080, that is 360dip wide.
Your nexus 4 has 320/160 = 2 real pixels per dip. So with a width resolution of 768, that is 384dip wide.
Neither device is more than 480 dip wide so both use the sw360dp folder.
Both devices are physically very similar in size. The Nexus 5 (5.4inch screen) has more pixels than the Nexus 4 (4.7inch screen) but the pixels are physically smaller. So it is correct that the same layout is used for both. The UI should look the same on both devices, assuming you correctly specify the size and layout of your various UI elements in dip.
As a further example, I have an old tablet (10inch screen) with a resolution of 800x1280 and a low density of 149, hence is 859dip wide. You can comfortably display far more info on a screen that size than on a Nexus 4/5, hence you might consider creating a layout-sw720dp for that.
So you appear to be doing exactly the right thing already by designing different layouts for different screen sizes. Just remember that resolution is not the same thing as screen size. Screen size is a combination of resolution and density.
As for your drawables, you are also already doing the right thing by using drawable-xhdpi, drawable-xxhdpi etc with appropriate resolution images in each one. So for example a small device with an extremely high density would likely use the 1440x2560 images and the sw360dp layout. My low res tablet would use the 720x1280 images, unless you'd put something in drawable-mdpi which is where it would look first.
So firstly you'd create appropriate resolution images in the drawable folders so that they would look as good as possible on different resolution screens. Then create appropriate swxxxdp for your layouts so they take up the appropriate space depending on the physical screen size, i.e. make good use of available screen space on large devices and don't clutter up small ones. It's likely you would want to go further and create -land and -port versions of each as well.
It is worth noting that even if you only have one layout folder and one drawable folder, your application will still work on all devices. Android simply looks for the best choice and if there is only one, it'll use that. Adding in the various folders simply allows you to make your app look as good as possible on a range of devices.
Everything I have discussed here and more is explained in detail at http://developer.android.com/guide/practices/screens_support.html.
I want Perfect Splash Screen Size for Smart Phones and Tables.
I have Size for Smart Phone but I am being confused after seen another some posts who are showing different sizes.
For Smart Phone :
drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi
For Tablet:
drawable-large, drawable-small, drawable-normal, drawable-xlarge<br><br>
Right now, I have sizes as per below :
xlarge (xhdpi): 640x960
large (hdpi): 480x800
medium (mdpi): 320x480
small (ldpi): 240x320
From Supporting Multiple Screens
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
Please help me regarding this. And also tell me size for Tablet Splash Screen Size.
First of all, the question is vaguely worded. What do you mean by splash screen size? Since you will be loading splash for full screen, what does pixels for screen mean? I am going on the assumption that this was asked for Image pixels for different Screen sizes and provide the answer.
I find image size for Perfect Splash screen size to be relative too as it also depends on the method used for the Splash Screen. Since the image you use can be set according to the size of the screen programmatically if it is required to fill exactly up to some percent of the screen without pixels having much of effect in that if you keep adequate pixelled image (if the splash screen is loaded as an activity for a specified amount of time from your MainAtivity). Now, if you are following the drawable method for creating splash screen using theme for calling it (like in Splash Screens the Right Way article), well then the Pixels of the image really matters as the size of the image will be determined by the different pixels used for images for different screen sizes. The answer to that is provided exactly in the android splash screen sizes for ldpi,mdpi, hdpi, xhdpi displays post.
For lazier developers like myself :P, I will provide the values below for minimum screen sizes (all in pixels), which are provided by Google (the statistics on the relative sizes of devices on Google's dashboard).
Android Mobile Devices :
LDPI- 426x320
MDPI- 470x320
HDPI- 640x480
XHDPI- 960x720
Android Tablet Devices :
LDPI- 200x320
MDPI- 320x480
HDPI- 480x800
XHDPI- 720px1280px
And ofcourse, the use of 9 Patch images are always recommended for stretchable images.
Dear All I’m going to work in android application I should design the interface. I read articles on http://developer.android.com/design/index.html but I still have some missing point.
Do I need to design back ground for each device size ?
Check for this Link for supporting multiple screen. This link will show you how to create the different layout for different screen size devices.
But even if you want to make a Unique layout for supporting multiple screen in orientation or portrait mode then,
For image, use 9 patch images.
Here is the link http://developer.android.com/tools/help/draw9patch.html
For width and height of any widgets, use wrap_content or match_parent or you can use android:layout_weight and android:weightSum
Avoid using the pixels i.e. px
Use dp
By this you can create the unique layout working for multiple screens, but that screen should be in orientation or portrait mode.
If you want to support for for both,then you have to createlayout-landfor landscape mode in the res folder.
Actually, you should. There are 4 main screen sizes in android those get layout xmls from res/layout-xlarge, res/layout-large, res/layout-normal and res/layout-small. At the same time, you should use different image resolutions for different screens those get images from drawable-hdpi, drawable-xhdpi, drawable-mdpi and drawable-ldpi.
It depends on the background type. If your background is an image with high resolution you should provide different images for different screen sizes if the whole background is an image.
You can also:
Make background from tiles (like icloud.com)
Specify a ninepatch image if your image is something like a frame where corners should remain the same and the body should be scaled (not very good if you have some picture)
Specify multiple different images for different screen resolutions and densities. To do so read supporting multiple screens. If you need even more precision in image scaling and quality you can use the fundamental size of screen attribute which is sw<N>dp - you can specify the smallest width of the screen where your image should be used. This is a qualifier name for a resource folder.
Some values you might use here for common screen sizes:
320, for devices with screen configurations such as:
240x320 ldpi (QVGA handset)
320x480 mdpi (handset)
480x800 hdpi (high density handset)
480, for screens such as 480x800 mdpi (tablet/handset).
600, for screens such as 600x1024 mdpi (7" tablet).
720, for screens such as 720x1280 mdpi (10" tablet).
You should also have a look at other qualifiers that make Android choosing image at runtime (screen density, Available width, Available height, Screen size or Screen aspect). By combining these qualifiers and testing carefully you will be sure that the user has the best experience on each device.
as per android developers docs, 96 X 96 px is the icon size required for high density screens . Can i use the same size icon for all the screens? or I have to provide different sizes for different screens like ldpi, mdpi . Also, png is the only format accepted or any format accepted ?
Also for splash screen, 1440 X 1080 px is for xlarge screens, so can I use this single image for all the other screens (like large, normal and small) Or do i have to provide separate images for all the screens ? Also, what formats are supported?
Please read about how to support multiple screens
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
You have to use separate images and separate layouts to handle different screen sizes. Otherwise for xlarge screens the image may be fine but for small screens it will get cropped. Same will happen with layouts. So for best programming experience please use separate files. Android supports files other than .png as well.
If you use one icon then Android system will stretch and set it for all other resolution. problem is your icon is stretch for large screen. then, it might causes to appearance of the application. so you have to think this.
if you use each icon for each display size, it may causes to apk file size. this is the same thing about other images that adding for different display sizes.so you have to consider this.
most of the time you can manage this with 9patch images to avoid this.
with my experience, I have notice that avoiding images that have circles makes not to use different images for different screen sizes.then you can manage it with less images.When they are stretched circles become ellipse.
I think now you have idea.