How to make your app graphically portable? - android

I'm new to developing Android games and I still don't have an idea as to how I can make the screen size for my game dynamic. Is this possible? Or do I really target a specific screen resolution? For example, if I have a 150 x 150 drawable in a 320 x 480 resolution, that would make the drawable large but what if the game is installed on a 1024 x 768 resolution? Any suggestions with this? Thanks in advance.

Android has several folders for different resolutions: ldpi, mdpi, hdpi, and, when using API-level 10 or higher, xhdpi.
The 320 x 480 resolution will use the mdpi folder, every step higher uses a factor of 1.5. So when your drawable is 150 x 150 in mdpi, you should make the drawable (150*1.5) x (150*1.5) = 225 x 225 for the hdpi folder.
You may also want to take a look at this.

Related

Android splash screen dimensions

I'm trying to create a splash screen on photoshop that will support every single device that runs Android. I've been reading around blogs and the android website and I see that you need to design your assets in dp, but I don't understand what that means. I understand the concept of dp, but I don't understand how to apply that on photoshop. I know the equivalent of a dp is pixels/(dpi/160), but I'm not sure what size (pixels) I should be using for each one of the different sizes (ldpi, mdpi, hdpi, xdpi, xxdpi...). So if someone can let me know what the dimensions of my splash screens needs to be, as well as the resolution, I'd really appreciate it.
ldpi = 320 x 426
mdpi = 320 X 470
hdpi = 480 x 640
xhdpi = 720 x 960
xxhdpi = 1080 X 1440
strongly recommend that images are no larger than 2,000 pixels wide with no more than 72 dots per inch (dpi). This keeps your Splash page loading quickly.

Using the formula px = dp * (dpi/160) for creating image resources does not result in sharp images

Although this question is not related to programming, it is related to app development.
Suppose I have an ImageView whose dimensions are 40dp*40dp. If I use the above formula to create an icon for a device with screen density 217 ppi, the size of the icon that fits the ImageView exactly is 55px*55px. If I use this icon in the view in consideration, the result is that the icon does not appear very sharp.
On the other hand, if I use a larger image of size, say 80px*80px, it appears sharp. So this larger image is larger than the exactly fitting one by a factor of 1.6.
What I would like to know is whether there is a certain value of the above factor that is most efficient and conventional. I would like to follow conventions while developing my apps.
Thanks for your time.
Your ImageView size is 40dp, thats equal to:
40 x 1.0 = 40 pixel on mdpi devices
40 x 1.5 = 60 pixel on hdpi devices
40 x 2.0 = 80 pixel on xhdpi devices
40 x 3.0 = 120 pixel on xxhdpi devices
40 x 4.0 = 160 pixel on xxxhdpi devices
Now your device is hdpi (217). for thats device you need a 60x60 pixel bitmap, and you have to put it in the drawable-hdpi directory.
Using drawable directory is like using drawable-mdpi directory. fro each resource in that directory android will scale it up/down before using it.

Understanding dpi and the drawable folders

Yesterday I already asked a question about this here. After that I saw this on the official android developer page:
So you can have a 1024x600px screen device with ldpi and a screen with the same resolution with mdpi.
Furthermore you can have a 600x1024px screen device with mdpi and a screen with the same resolution with hdpi.
I have an image, that takes 20 % of the screen's height and width on every device.
I want to make 5 versions of that image (with different resolution) for each drawable folder.
In my past thread I got this answer:
ldpi: 0.75
mdpi: 1.0
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0
These are the scale factors.
So if my image has a resolution of 50 x 100 px in mdpi it is supposed to have a resolution of 75 x 150 px in hdpi.
I understand that.
The question now is, how am I supposed to know what resolution my image should have in the mdpi folder, if the resolutions for mdpi are totally different (as you can see in the image above -> from 320x480 to 1280x768).
Thanks !
The drawables should be created at a resolution that makes them the right physical size when displayed on the screen. If you have an icon that is supposed to be 1/2 inch by 1/2 inch on an MDPI screen, then the image should be 80px by 80px. This size should be irregardless of the physical dimensions of the screen; the same drawable on a 1280x768 MDPI tablet is supposed to be 1/2 inch by 1/2inch.
If the icon in question should be larger on the tablet for some reason, then you would need to introduce the drawable-swXYZdp-mdpi folder that Der Golem mentioned above. In this folder, you would be able to create a version of the icon that had a larger physical size (say 3/4 inch) that will be loaded on the tablet.

creating Android assets (LPDI,MDPI,HDPI,XHDPI) for an app?

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.

How to implement an application to take image from appropriate folder?

i am working on an android app. as this should be all screen size supportive .but it is not working properly.
I can I set that for 480*800 size it will take images from drawable-hdpi folder?
Screen size and dpi aren't the same thing. DPI is the number of pixels per inch. a 480x800 screen can still be any dpi level- it would just be a smaller screen with higher dpi.
You can try doing a size override with drawable-swNdp where N is a pixel value. That works for layouts, I believe it also works for drawables.
To support on all resolution devices put different resolutions images in different folders in drawable as,
drawable-ldpi - 240 * 380
drawable-mdpi - 320 * 480
drawable-hdpi - 480 * 800
drawable-xhdpi - 720 * 960
For more info about resolution refer this link :
http://developer.android.com/guide/practices/screens_support.html

Categories

Resources