I am looking to support a devices (TVs, tablets , phones)
I have the following directory setup.
res/layout/
res/layout-small/
res/layout-large/
res/layout-xlarge/
I expected layout-xlarge to target only TVs but it seems to target my 10 inch tablet as well.
Can anyone tell me why this is?
Should I try using the screen width directory structure/
e.g. res/layout-sw600dp etc.
Using '-small', '-large', etc, targets the resolution. So a small device with a high DPI would count as an '-xlarge' (For instance, the Nexus 5).
The correct way to do it, as you said, is to use the dp structure (-sw600dp, as you said).
dp in Android is a unit for density independent pixels:
What is the difference between "px", "dp", "dip" and "sp" on Android?
Using 'tvdpi' might be a good idea for targetting TV's as well.
Here is a good resource for this information:
http://developer.android.com/guide/practices/screens_support.html
I use the following:
-sw320dp (or default) for smaller phones
-sw360dp for regular phones
-sw480dp for huge phones
-sw600dp for 7" tablets
-sw720dp for 10" tablets
You can also specify pixel densities, such as -ldpi, -mdpi, -hdpi, -xhdpi, and -xxhdpi.
Here's a screenshot from one of my projects. Here, I attempt to provide the perfect images for all screen sizes and densities. This may be overkill for what you are trying to do.
For more information, please see http://developer.android.com/guide/practices/screens_support.html
Related
I have a recycler view on my android app main page that displays a list of pictures and I can't decide which width to give my images so that they are not too heavy but still very neat. (My images take the whole width of the screen.)
I know every Android device has a different format but I need a one-size-fits-all.
I currently have images on my res folder with width 500px (and approx. 350px height). The images weight between 30ko and 100ko. But I must admit they are not very neat ...
So I guess I have to pack pictures with a greater width to gain quality, but I have no idea how much.
How does Instagram does it ? Pictures are always very neat, how do they do this ? What are the characteristics of their pictures ? I guess they weight a ton, no ? (like 500ko per image ?) or am I wrong ?
There are utilities ('Image Optimizers') that shrink jpeg images without any significant quality loss, you can find some of them on Google for manual use.
When showing a lot of images, you can use a library such as Compressor to do this for you. I believe that apps such as Instagram might have their own code but same same. The file sizes are usually 15-300 kb, depending on the 'complexity' of the image.
After spending quite some time testing on different sizes and weights, my conclusion is that 500px wide images are not displayed very well on devices in general when you want to have image that take the whole width of the phone. But you can have light images (between 30Ko and 80Ko).
Below 500px width is not a good idea.
When you go up to 1000px wide images, you get a whole better quality, that gives your app a better look and feel in my opinion. But obviously images are somewhat bigger (between 80 and 190Ko)
When you go up to 1500px wide images, you have to be careful to the weight of the image. I wouldn't recommand having images that weight more than 200 Ko. But at least you got very good quality ... which is something nice :D
I hope that could help
I need to know how my game can handle all these screen sizes i have seen a few options including:
Re sizing the elements to fit the screen
Making assets in lots of different sizes
I'd like to know which is more efficient ?
What are my other options ?
How would i go about making it work ?
So far i am just making my screen fit to the android device i'm testing on and this could lead to failure in the future if i do not set this handler up
Thanks
well if you are using libgdx then you dont have to worry about screen sizes. just use its camera class and set its viewports accordingly . refer this link for camera
Also you dont need to make android handlers for it.
This website talks about how to handle this problem http://developer.android.com/guide/practices/screens_support.html.
It claims the best practices are:
Use wrap_content, fill_parent, or dp units when specifying dimensions in an XML layout file
Do not use hard coded pixel values in your application code
Do not use AbsoluteLayout (it's deprecated)
Supply alternative bitmap drawables for different screen densities
The problem is not with the dimensions of the screen, rather the density of the screens. Using dp to set the size for elements is the most common way.
I am working on a photobooth type app for iPhone and Android. On iPhone, I know the exact resolution of the front camera, and am able to always output 4 mini pics predictably and make a photostrip from them. But for Android, I need a way to resize 4 images I have taken to a width of 48px and height of 320px per image. This way, I can build the same size photostrip I built for the iPhone version, and easily display the photostrips in a consistent manner on a website (I don't want the size of them to vary depending on platform). On Android, how can I resize to that resolution (48x320), even if the Android camera doesn't output that aspect ratio? Basically, I'd like to resize on Android, and have it automatically zoom as necessary until 48x320 is reached and it doesn't look stretched/distorted...I'm ok with part of the image (like the outside border) being lost in favor of getting a 48x320 image. Maybe this is just a straight Java question...
Thanks so much!
I'm getting into app/game development for android and I just wanted to know how hard it is to make your games work with all phones. or do the phones just scale the app to fit with the screens? thanks for any help
Screen resolution isn't as big a problem as the differences in screen ratios and defining things like touch-area sizes.
The commonest devices that my games and apps are running on have the following sizes...
320x480 (4x6)
480x800 (3x5)
480x854 (it defies belief to try to give a ratio to that nonsense)
I use AndEngine and libgdx - both will scale automatically BUT I have to choose a ratio to work with and it will crop (with black bars rather than lost content) on devices which don't share that ratio (for reference I choose to crop lower-resolutions as I think people with nicer screens would complain sooner!!)
Actual physical screen sizes vary too - and you have to bear-in-mind that a box which may seem big enough to hit on a 4.3" high-density phone could be near-impossible to hit on a smaller/lower-density device...
Both of those things are far more worrying than scaling...
You should remember that screen resolution is only one of many factors deciding about game compatibility.
I think this video is a good for start
http://www.google.com/events/io/2011/sessions/building-aggressively-compatible-android-games.html
Table 3 on this page:
http://developer.android.com/guide/practices/screens_support.html
shows that WVGA800 (480x800) is available with 3 Densities. Does this mean that for each density the game will be loaded with different DPI assets if available ?
But how come same resolution will have different assets or layouts?
Well a certain resolution say 480*800 surely can have different densities....And the assets would be placed in their respective places...Suppose say images for though accomadating as per 480*800 would be placed in different drawables hdpi,mdpi,ldpi... Depending upon your desity type the appropriate drawable would be used automatically...
Though the layout would be same for different densities....But assets and other would vary to give you actuall look and feel..
Hope you would be able to get what I want to convey...
Go through this blog to get a basic understanding for what I mean...
http://wonton-games.blogspot.com/2010/07/tutorial-multiple-screen-support.html