I need my app to support 480x800 normal hdpi and 480x800 large mdpi screens. The UI for them is the same. The matter is using dp in this case is a wrong way because on hdpi device everything becomes larger. But I need just scalable UI.
Is it possible I provide that by using single version of layout files?
use 2 set of images and put in the 1.x mdpi and other in 1.5x hdpi
here 1 and 1.5 is size ratio
only one layout xml file is enough.
EDIT:
//while design keep in mind with 1x that is mdpi
//for example if you set 5dp for you mdpi resolution
it will automatically change for hdpi as
5*240/160=7.5 px //for hdpi
5*320/160=10 px //for xhdpi
Related
I am having trouble configuring my Android application for another screen density. Currently, my app runs on HDPI (1.5) screens and I am trying to get the dimensions of my pngs and my values in my dimension.xml to be compatible with XHDPI (2.0) screens.
For example, my background png is currently 1280px x 800px and it works well with my HDPI (1.5) screen. I assumed this would mean that I would need a 1280 * (4/3) = 1706.67px by 800 * (4/3) = 1066.67px dimension png. This did not show the same as my current tablet.
Also, my screens are almost exactly the same size
LDPI = 0.75x
MDPI = ORIGINAL
HDPI = 1.5x
If you have an image 1000X1000 (pixels) you have to create the following versions of the image:
LDPI = 750x750
LMDPI = 1000X1000 (THE ORIGINAL IMAGE SIZE)
MDPI = 1500X15000
Except, in #dimension, HAS NOT put some values "dp" or "sp" and then used them in the style of the image.
never use px in xml. It just need two kinds of pictures,one is xxhdpi,other one is xxxhdpi.If you need a xxxhdpi picture but drop it in xxhdpi's folder.That will influence your memory.So use xxhdpi and xxxhdpi is enough.But you need use dp or match_parent or weight to profile you png's size.
I am working on Andoid application for mobile only(Not for Tablet). So I am going to tell designer to make PSD for android screens. Generally I tell my designer for making application design on these three sizes and I use dimen to adjust layout for other devices:
320* 480 (and I put these images into mdpi folder)
480*800 (I put these images into hdpi folder)
800*1280 (I put these images into xhdpi folder)
So I want to know what size of PSD should I made from my designer.I am asking about complete screen size.
//For Designer
start design PSD file from 100% i.e design from XHDPI then need to downscale it to
75% for HDPI
and 50% for MDPI
//For Developer
start design for MDPI first then place drawables in appropriate folder
Baseline phone mdpi 320x480
from that you can increase you drawables as 1.5 for HDPI and 2 for XHDPI
Developer keep in mind while designing layout ref best Practices
1. Use wrap_content, fill_parent, or dp units when specifying
dimensions in an XML layout file.
2. Do not use hard coded pixel values in your application code
3. Do not use AbsoluteLayout (it's deprecated)
4. Supply alternative bitmap drawables for different screen densities
Different screen pixel ratio :-
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
http://developer.android.com/guide/practices/screens_support.html
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
Well, I'm working on the UI for my Android app. And regarding the variety of screen sizes and resolutions, I'm following the known recipe:
MDPI 160DPI 1X (1px)
HDPI 240 DPI 1.5X
XHDPI 320 DPI 2X
Considering this scale, it means manually resize all my icons and buttons on Photoshop, and then load them into the respective folders (mdpi,hdpi and xdpi).
Do you do this in the same way? There is some sort of "auto scaling mode" or something on Android?
All the best,
If you don't want to generate all the icons for all dpi fragmentation, there's a trick. Just generate the icons for xxhdpi or xhdpi and add them into the respective folder. Android itself will resize them in order to fit another fragmentatios but remember that the scale is always done from bigger sizes to smaller, not in the other way.
Hope that helps
I Need to create a Designs for a Andriod Application.
I can see everyone are speaking about this "ldpi,mdpi,hdpi & xhdpi....etc.," My biggest doubt is in WHAT RESOLUTIONS, I should create the designs in Photoshop?? As there are lots of screen sizes available now. WHAT DEFAULT SCREEN SIZES I SHOULD DESIGN WITH FOR EACH "ldpi,mdpi,hdpi & xhdpi ?" Like for Xhdpi - What Screen resolution Should I do ?
a. 720x1280 - 320 dpi
b. 2048x1536 - 320 dpi
c. 2560x1536 - 320 dpi
d. 2560x1600 - 320 dpi
Again the same resolutions for ldpi,mdpi and hdpi ? What Screen Resolutions for the respective DPI's
Which Screen Resolutions for
a. 120 dpi ?
b. 160 dpi ?
c. 240 dpi ?
PLEASE CLARIFY ME GUYS.
THANKS A TON IN ADVANCE
See this calculator.
ldpi is 120 dpi
mdpi is 160 dpi
hdpi is 240 dpi
xhdpi is 320 dpi
xxhdpi is 480 dpi
xxxhdpi is 640 dpi
(Thanks to Tobor for adding those last two and correcting my typo, I accidentally overwrote his edit)
Also, I don't know why Maneti's initial advice was downvoted. When in doubt, use this tool (or the one in your android sdk) to generate your icons, then import those icons you generated into Photoshop. That's actually the most pragmatic and easiest solution (that doesn't require any thinking on your part and yet that solution works all the time for densities).
As to the size of an image (as defined by the Android guidelines/terminology), only worry about the size of that image if it's a image that could potentially take the entire width, or the entire height, of the screen (like a large background image for instance).
So in most cases, most developers end up not needing the size qualifier for their drawables (because it won't make a difference unless it's a large background image).
For 120, 160, 240 dpi, respectively, I'm condidering 240*320, 320*480 and 480*800 (or 854) screen sizes.
For xhdpi (320) I'm considering 1280*720 (or 800).
But this is only a reference
Take in account that your design should scale
So, the graphical elements should stretch or be repositioned well.
After all, the screen size is not so important, if you project your objects positions and sizes well.
Use dp for objects and sp for font sizes, use the proper dpi resolutions for graphics and you shold be fine.
You can't follow any existing resolution. Generalize.
You could start with with XXHDPI and then export your assets from there. I found that 1080px x 1920px and 72ppi is a comfortable size to design in Photoshop and allows you to export to other resolutions by downscaling (you should avoid scaling assets up). You can then you use this Photoshop script I wrote or Cut&Slice me to export assets from that document to the other resolutions (XHDPI, HDPI, MDPI, and LDPI).
I would also recommend using a Sprite Sheet PSD for your assets to keep things clean and organized.
Hope this helps.
first I think you meant ppi not dpi.
second since the graphics are intended to be used on screen only the size in pixels matters. The ppi could be what ever you want.
ppi (pixels per inch)/dpi (dots per inch) is used to measure the resolution of the output in the real world.
So why people use ppi if it doesn't matter?
Some people like to use the ppi when sizing the files for proportions. This way you can change the ppi number and get the proportions right.
let's assume you start with xxhdpi with a ppi of 480.
Then if you change to 320 you will get xhdpi
240 > hdpi
160 > mdpi
120 > ldpi
but you can use percentages as well.
I've read 10 articles yet still cant find any relation between ldpi, mdpi, hdpi and the actual dimensions in pixels!? Can anybody give a straightforward answer please(if there is one!)
I'm basically trying to put together a splash screen that needs to work on multiple devices without stretching - but i'm struggling as everything I try is either squashed or stretched!?
Cheers
Paul
The ldpi, mdpi and hdpi refer to screen density, which means how much pixels can fit into a single inch.
the ratio in pixels between them is:
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
xxxhdpi = 1:4
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
for xxxhdpi it should be 400X400
this way, for screens with the same size but different DPI, all the images seem the same size on screen.
Also you have multiple screen size types small, normal, large, xlarge and each one of them can be ldpi, mdpi, hdpi, xhdpi, xxhdpi (Nexus 10) or xxxhdpi.
You can try to create a splash screen image that fit to each and every screen type
which gives you 4*5 = 20 different images (it seems to much for me).
For now only the Nexus 10 is at the xxhdpi category.
Install ImageMagick and use this shell script to generate your splash and icon files for multiple devices - iOS, Android, Bada and Windows Phone. You can use cygwin/gitbash if you are on Windows
I just did and I'm pretty happy with it :-)
The screen sizes are inside the script and are -
480x800 - screen-hdpi-portrait.png
320x200 - screen-ldpi-landscape.png
720x1280 - screen-xhdpi-portrait.png
320x480 - screen-mdpi-portrait.png
480x320 - screen-mdpi-landscape.png
200x320 - screen-ldpi-portrait.png
800x480 - screen-hdpi-landscape.png
The definitions are:
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. (Android does not currently
support screens smaller than this.)
Also, check out this blogpost from Dianne Hackborne:
http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html
Probably the easiest thing is to use an image view and set the scaletype to CENTER_CROP.
(Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view).
Make sure that you use the src tag rather than setting the background.
<ImageView
android:id="#+id/home_video_layout"
android:src="#drawable/splash_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
/>
Updated:
Understanding Screen Densities and the “dp”
Resolution is the actual number of pixels available in the display, density is how many pixels appear within a constant area of the display, and size is the amount of physical space available for displaying your interface. These are interrelated: increase the resolution and density together, and size stays about the same. This is why the 320x480 screen on a G1 and 480x800 screen on a Droid are both the same screen size: the 480x800 screen has more pixels, but it is also higher density.
To remove the size/density calculations from the picture, the Android framework works wherever possible in terms of "dp" units, which are corrected for density. In medium-density ("mdpi") screens, which correspond to the original Android phones, physical pixels are identical to dp's; the devices’ dimensions are 320x480 in either scale. A more recent phone might have physical-pixel dimensions of 480x800 but be a high-density device. The conversion factor from hdpi to mdpi in this case is 1.5, so for a developer's purposes, the device is 320x533 in dp's.
I have found this online dip <--> pixels calculator very useful.
https://pixplicity.com/dp-px-converter/
I support previous answers but don't forget the power of Draw9Patch or using NinePatchDrawables
These refer to screen pixel density, not screen dimension. You need to look into screen size specifiers like small, medium, large, and xlarge instead if you really need to change behavior based on screen size in pixels.
The Android docs explain what densities and sizes match these identifiers.
Android devices can have different width-to-height ratios, while your image has a fixed one. If you do not want your image stretched, you will have to fill the blank spaces above and below or left and right.