Android app for different screen size - android

i'm an italian guy and i'm developing an android app for a course that i'm attending at Information and Communication Technologies university.
This is my question: following android philosophy, it is right to create 12 folders for different values of hight and width (in dpi) in android?
I mean:
values-ldpi
values-mdpi
values-hdpi
values-xhdpi
values-small-ldpi
...
...
...
values-xlarge-hdpi
values-xlarge-xhdpi
I can't use "match_parent" or "wrap_content" everywhere, so for some components i have to specify the size in dpi.

That is correct, but you can get a whole way by simply putting up your XML layouts smartly, using Fragments and thinking of a design that allows the use of some relative position descriptions.

Your solution is certainly the most exhaustive and thorough. It isn't necessarily "right" as you say though.
Ideally you would be able to create values/layouts/drawables for every possible combination of screen size/density. In the real world, it is more common to focus on a particular subset.
For example, you can have a look at the most commonly used screen densities here (updated periodically).
There are particular drawbacks to being exhaustive, including large .apk sizes if you are dealing with drawables, and as such you can scale back your approach and focus elsewhere, or release multiple .apk's for your application.
There is an in-depth article on Supporting Multiple Screens on Android here which is well worth a read.

There is not a generic rule that can work always.
In some cases you could have to use values-land, values-v14, values-large-land-v14, values-sw720dp....depends on the app you want to achieve.
Don't forget values-xxhdpi

Related

Android design for very similar (but different) devices

The answer to this may be, 'you poorly designed your app', which is likely as I'm still pretty new to this.
Issue: I have small game that I created where the background image of the screen is the game board. On it, are locations for scoreboards (part of the image). I am using textviews as the different scores that will display on 4 score boards. My issue that I am trying to address is keeping the textviews placed where I need them, directly over the score board images, when different size and density devices are used. (things move around).
I have this working great on many different devices and densities using multiple resource qualifiers on my values folders. For examples...
sw320dp-xhdpi
sw400dp-mdpi
etc.
I am running in to situations where I have two devices that are both xhdpi and their resolutions are very close.
device 1: 1280 x 720
device 2: 1280 x 768
As I have things currently, this will result in both of them using the same dimens file that is being used to place the text views. Ultimately, this results in one of them aligning things perfectly and the other being slightly off.
Is there a way handle one of them uniquely via a 3rd resource qualifier?
Is there a different way to handle this outside of resource qualifiers?
Did I approach this poorly and there is a much cleaner way to handle what I am trying to do?
Thanks,
Bob
This may not be the in-depth answer you're looking for, but Google announced their new version of Android Studio a while back. It includes the ability to make one layout fit all devices. Check it out:

stabilize android layout design for tablet and mobile

Actually I need some suggestion like Designing screens for android mobile as well as tablet. As of now im creating two different folder for xml one is for mobile and another one is for tablet. Im placing images in 4 different images with 4 different resolution like (160 dpi, 240 dpi, etc). so am i going in right way or i need to change the way of designing. Thanks.
When designing for different devices it is important to test whether there is a necessity to create different layout files for the different devices. If you find that you do want that then there is plenty documentation online about it. Read these first:
Designing for different screen sizes
Guide lines
More android screen size documentation
Each of these links explain the new methodology of designing for multiple screen sizes.
A few tips on top of the already answered question that I gained by experience:
Use #dimen everywhere you have to specify a width/height but in general, avoid specifying them if you can. This way, you can override the dimension based on the available DPI and don't have to replicate your layouts.
Use LinearLayout wherever you can and use weights to determine how things should be drawn. Other layouts like relative layout are fine as long as they're used for positioning (isLeftOf for instance) as opposed to making a certain space available.
Use fragments wherever you can. It's much easier to work with self contained fragments. In general, avoid having any UI logic in your activities and let the fragments handle them.
Use the Android Asset Studio (http://romannurik.github.io/AndroidAssetStudio/icons-actionbar.html#source.space.trim=1&source.space.pad=0&name=ic_action_example&theme=light&color=33b5e5%2C60) which will take care of resizing your images for you. It's been very valuable to me. Have a look at these other projects too. They can help you in many aspects when designing your UI: http://romannurik.github.io/AndroidAssetStudio/
Even when you do all this, you may come across a scenario where you really do need to write a different layout for tablet and phone. If this is the case, as long as you've created everything in self contained fragments, it's much easier to switch fragments or even use the same fragment code with different layouts (as long as they contain the same UI elements) depending on the dimension. It would also be advisable to use the trick here (Determine if the device is a smartphone or tablet?) to determine if you're running on a large/small tablet or a large/small phone.
All in all, it's a little bit painful developing and testing your app on all the available device sizes but as long as you follow the above points, you'll have an easier time.

Android App XML multiple screen support

I made a calculator app and used density independent pixels to create the layout, place the buttons and so on. Yet on a tablet emulator it doesnt display correctly, it only takes about 1/4 of the screen. On my phone(800x480) everything is ok. How can I adress this issue?
You'll need to provide additional layout folders for the different screen sizes so that the Android system doesn't use the same one by default, resulting in the behavior you've described.
This is accomplished by adding layout folders with size specifiers such as: small, medium, large and xlarge.
layout-small is an example.
So, to be clear, you're adding additional folders for the different supported screen sizes. You'll then add a layout of the same name to each folder you add. The system handles the headache.
You would then alter the layout to achieve the best results. Note that it is common practice, when dealing with larger screen sizes, to provide more content on a single screen as opposed to blowing everything up. If your app can benefit from that, it looks better than having obscenely large buttons stringing across the screen, IMHO.
For a complete run down, please refer to Android Documentation.

Supporting multiple screens in Android for numerous activities and resources

I have around 10 activities in an app and around more than hundred images. Now need to provide support for multiple screens of diff sizes and densities. If I need to create for small,large and xlarge sizes even though it will be customization of 30 more activities rest aside diff densities for a specific size :O Is there any way I can stretch the whole layout depending on the size and densities, I mean what is the best way to solve this problem. It must be a very common problem but I am missing something here. I read the android dev. screen support doc but still confused. Any ideas? Thanks for your help.
It's hard to give an answer specific to your project, but in general Android does a good job of this all by itself. All layouts will automatically scale if you haven't specified fixed dimensions (ie using px instead of dp). When it comes to fullscreen images (background and the like) it is best if you provide several resolutions (in the drawable-mdpi, drawable-hdpi etc) folders. You may also have to look at the scaleType for an ImageViews you may have.
Read through the official documentation on how to support multiple screen resolutions. It provides all the information you need and it goes into detail on how to provide different layouts not only for different screen resolutions, but also for different screen orientations and things like smallest width etc (for tablet specific layouts)

What steps do I need to do to get my game working on multiple resolutions?

I have a written a game that works fine on the 'normal' 320x480 screen of my G1.
I tried it on a friends Xperia x10 and it leaves a large blank section on the right hand side of the screen.
How do I fix this? I've read that I need to include an extra directory in res/drawable for different densities. How do I do this?
Thanks for any help
Caroline
The table on the page that Yoni references describes the various screen sizes and resolutions that are currently available.
Check the best practices on the same page:
http://developer.android.com/guide/practices/screens_support.html#screen-independence
If you follow the steps mentioned there, you shouldn't have any trouble. If you have set the resources up correctly (i.e., using dip rather than px), resources will scale, so you do not necessarily require different size resources (though you may want them in order to keep things looking nice).
I'd suggest using either mdpi/hdpi or normal/large for your resources - having both is overkill.

Categories

Resources