Testing Android application with different-sized screens - android

I have a question for you guys about multiple screens.
I am testing an Android application for different-sized screens using emulator. The application have been initially developed for resolution 320*480. I know it is not good and I have problems in my code. Moreover, I have used pixels in some places of code instead of dip. You see, I am not a professional in Android. In any case, there is no problem for devices with resolution 320*480 and 480*800. For the second one the application looks stretched. According to documentation it should be so. But, when I am trying resolutions 540*960 or 1024*600 the application occupies just a part of screen and it seems to be 320*480. The question is: why it didn't stretched the application to the whole screen? How can I do it?
I have read Supporting Multiple Screens guide here: http://developer.android.com/guide/practices/screens_support.html#dips-pels, but I haven't found an answer for my question.

Have you go through this lines in the link given by you?
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size i
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
for different size devices, make different folder as given above like layout-small,layout-large.. and put your designing xml in that.
Hope this help you.

Related

How does android choose the right layout/drawable for the correct screen resolution?

I that When starting an android application, android makes a good "guess" as to which layout/drawable to use depending on the screen size. However, I was wondering where it chooses this from? I ask this because I have quite a few layouts which don't all work. I read on the android website that you can make a folder called layout-xhdpi, layout-ldpi... etc. But does android automatically look for layout-xhdpi or layout-ldpi or do I need to specify that anywhere?
Same goes for drawables. When creating a new application in Eclispe it makes automatically drawables folders for you but does this necessarily mean it looks for those.
Conclusion:
Where does android look for alternative screen sizes and how/where can I change that?
Create following layout folder
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density

how to design android cocos2d app for multiple screens

I am working on Cocos2d Android,in cocos2d images are saved in assets folder, here we can't take images ldpi,hdipi,mdpi images. So which size images are best for supporting multiple devices(phones and tablets). I have taken small size image(240x320), I am resizing images, so its supporting for all devices, but images are looking blur. so which size image is best to support all screens both tablet and phones. Please suggest me.
the best way is taking the highest resolutions pictures ie. the size of the highest android screen size. and cocos2d will adjust for small android phones according to the screen sizes. Blur will happen when you take small images and enlarge it for big screen android phones.
But if you use multiple png files it increases the app size.
source-I made a game using cocos2d in android.
This is how you can arrange stuff in project
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
and this link will tell rest of the story

Application to support multiple screen resolutions

I have 3 layout folders in my project:
1. layout
2. layout-large
3. layout-small
and as of now i don't have anything in layout-small but layout has layouts with small dimensions and layout-large has layouts with large dimensions.
The problem is:
when i test my app on a 240x320 it uses layouts from layout
when i test my app on a 480x800 even now it uses layouts from layout
Is it because thought i have layout-large, 480x800 doesn't fall into large screens, hence uses the default layout folder?
If that is the case, how can i make layouts for Normal Screens there is nothing like layout-normal or layout-medium.
Moreover, if i design my layout for HVGA (320x480) it should work perfectly for WVGA800 (480x800) since they both fall under same screen size, only density changes. And i am using dp everywhere. Am i right?
any help appreciated.
When it comes to xlarge, large and small then it is depending on size(inches) not on dpi of your device
see below for specification
Additionally DPI is basically for Drawables while SIZE is for Layout.
Just use the following details it may work but i am not sure..
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Just try....
You should check this developer page out it helped me alot. http://developer.android.com/guide/practices/screens_support.html
Even if they have different resolution or screen size that doesnt mean that they have different pixel density. For example a large screen may have less pixel density than a smaller screen.
Another example would be the Samsung Galaxy tab which is 10.1 inch but is still mdpi-large and Nexus One which is less than 5 inch but uses hdpi.
Best of luck
I think I got what is going wrong with you........ lets try this.
suppose you are going to make the application compatible for 480x800 resolution.So for that first of all create two folder for it i.e.
1.layout-sw480dp this is for landscape.
2.layout-sw480dp-port for portrait mode.
Now,put all layout of the resolution of 480X800 in it.you see it will run easily on the particular resolution.
Note:- point here to be noted that for any device resolution let A X B. the name of the layout folder is goes like this.
1.layout-swAdp.
2.layout-swAdp-port.
here "A" is the screen resolution height value of device.
i hope it work for you.

Using different resources for different layouts. Layout distinctions

I've got a layout-normal and layout-large. Additionally, I provide several splash images with different resolution: 480x800 and 1280x800.
My problems are:
In my task it's said that I must distinguish layouts based on device resolutions(one for 480x800 and the other for 1280x800). Is there any possibility to implement it ? Taking in consideration an assumption that handsets have 480x800 resolutions and tablets - 1280x800 and higher, I could implement this scheme but I'm not sure that it's true.
I've created a test project where I attempted to distinguish layouts based on size, but I can't make android use 480x800 image for layout-normal and 1280x800 image for layout-large: in both cases it shows the 480x800 image. I guess, it's because of size, in case of a device, not equals resolution, in case of an image. However, I need to provide completely different looks for 480x800 and 1280x800. what are my options here ?
Thanks.
PS I'm building against Android 2.3.
You have the "Supporting Multiple screens" documentation that helps on that matter.
For example, the following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density

Android UI design based on screen resolution

I'm looking to make an Android app that changes the look of the UI based on the device it's shown on (4 inch phone, 7inch tablet and 10inch tablet). I know you have the fragments API and it's probably that which I should use for this, but all the examples I've seen just have 2 activities sitting side by side and the code is a bit OTT for my needs (they have events passing between them etc).
Here is the comparison between a 4 inch device and a 7 inch device and how the different UI elements should move around (also note that element A can change design between the two devices).
Any ideas on how I would go about doing this, or if anyone has any sample code that would be fantastic!
I think you should probably design different xml for each size. You can use the qualifier in the layout dir for different screen size. http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources
You can use different directory for different size :
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
and for more information :
http://developer.android.com/guide/practices/screens_support.html
Good Luck,,, :D
See also Fragments for Android 3.0+.

Categories

Resources