WVGA800 (480x800) & Density ANDROID - java

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

Related

What width should my images be to be neat on my app?

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

java lang RuntimeException:

so basically, i'm new to java and android studio. I know the basics but I'm not that good yet.
I get this error when I try to run an the app on my phone. Going through other threads didn't help me either as I basically have just one background image in the MainActivity. I have to add one more but when I do it and try to run the app, it crashes.
size of background image: 115kb
size of the image I still have to add: 164 KB (tried to compress it to 74Kb, didn't work.)
java.lang.RuntimeException: Canvas: trying to draw too large(430377192bytes) bitmap.
I saw this in another thread which was supposed to be put in the manifest which hasn't helped either:
android:largeHeap="true"
I hope I have provided enough information needed to answer the question, if you need more please tell me.
Again: I am new to this.
430377192 bytes is the equivalent of a 10372 x 10372 pixel image. This is much too large. Moreover, it is far larger than any Android device screen that you are ever likely to encounter.
So, find this drawable resource, and reduce its resolution to something more reasonable.
If you placed this drawable resource in res/drawable/, please understand that res/drawable/ is a synonym for res/drawable-mdpi/, representing images designed for -mdpi screens (~160 dpi). Those images will be upsampled to higher resolutions on higher-density screens (e.g., double along each axis for -xhdpi screens). Either prepare dedicated drawables for appropriate densities, or move this image into res/drawable-nodpi/.

What is the best way to target multiple device sizes?

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

Android handler for different screen sizes

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.

Can I user a layout on the android to render just part of an image at a time?

I have an image file that has all the character sprites that I will be using in a game, and I want to make a layout that will allow the user to cycle through each image to be able to pick which one they want. So, I have one large image, and I need to render just a small (32 x 32) section of it at a time. Is that possible with the layouts or will I have to use a canvas, and manually do most of this?
Yes Try using scrollX and scrollY. You can set these properties programmatically or in the layout xml.
That said, loading just the small images that the user needs to see is preferred to loading a large image containing all. If your image is really large you might want to consider the first option.

Categories

Resources