Support-Screens in Manifest File [duplicate] - android

So I used the following code below to have my application to scale screen size on different android devices but when I am testing on my Nexus 7 its does not scale and its as if it was on a 4 inch screen. When I run it in the emulator on a 7 inch screen it works. Anything wrong with my manifest file?
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:anyDensity="true"
/>
this code goes right before the "application" part right?

Ok, so what you have to know is that support-screens doesn't make your application look 'nice' on screens you are supporting (check this link). It just tells that users with such screens will be able to download your application, but it's up to you to make it display properly. You have to create layouts for specific screens on your own.
More about it you can read in Android's documentation: http://developer.android.com/guide/practices/screens_support.html
Basically, you have to properly name your directories in which layout files are stored in order to let Android know which one should it pick up for specific device. If for example your layout's file was "layout.xml" you should have:
/res/layout/layout.xml // Default layout
/res/layout-small/layout.xml // Small screens
/res/layout-large/layout.xml // Large screens
/res/layout-xlarge/layout.xml // Extra large screens
You can go even further and make also different layouts for portrait and landscape views by specyfing another keyword in directory's name:
/res/layout-small-land/layout.xml // Small screens, landscape view
/res/layout-small-portrait/layout.xml // Small screens, portrait view
Remember that tags order is important, so you can't write layout-portrait-small.

Use Relative layout it will solve most of your problem .Additional use Folder name with given below
the way i am dealing with multiple screen is this way and its working fine.....if any one has improved wayso do guide me
Screen size 480x800
layout-normal-hdpi-480x800
drawable-normal-hdpi-480x800
Screen size Galaxy Nexus--- though its size is 1280x720 but in actual due to system bar its dimension(screen size) differs
layout-normal-xhdpi
drawable-normal-xhdpi
Screen size Note 5.3---
layout-normal-xhdpi-1280x800
drawable-normal-xhdpi-1280x800
Screen size S3---
layout-normal-xhdpi-1280x720
drawable-normal-xhdpi-1280x720
Screen size 7inch tab 2 supporting OS version 3 and above--- dont write dimension 1026x600 bsz in actual due to system bar its dimension(screen size) differs
layout-large-mdpi
drawable-large-mdpi
Screen size 7inch tab p1000 etc supoorting os verion less than 3---
layout-large-hdpi-1024x600
drawable-large-hdpi-1024x600
Screen size 1280x800 tab 10.1,10.2,note 10.1 etc--- you can add dimension if you want other wise it is fine
layout-xlarge-mdpi
drawable-xlarge-mdpi

Related

Screen Size Compatibility

I'm starting just starting out in android development. My IDE is Android Studio and I'm currently building my own calculator app. I used Nexus 5X
's screen which is 5.7":
My app using the 5.7 screen
The only problem I encountered is that when I tried to my friend's phone which has a 4.7 screen, it somewhat looks like this:
My app using the 4.7 screen
I thought that it the app would automatically scale everything just like when you're using viewport on web development. I'm a web-developer (html, php, javascript, css) and I'm planning to migrate to android development for ease-of-use. Is there any way to fix this without re-designing everything again guys?
Thanks, and peace out.
Android devices come in a variety of screen sizes and resolutions. That’s why handling the multiple screen size in android is most important.
Look into this: https://stuff.mit.edu/afs/sipb/project/android/docs/guide/practices/screens_support.html
Actual physical size, measured as the screen’s diagonal.For simplicity, Android groups has four generalized sizes: small, normal, large, and extra large.
To set up support for multiple device sizes in Android, add the element into the AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest ..>
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens= "true"
android:anyDensity="true"
/>
<application... >
….
</application>
</manifest>
As we design our UI for different screen sizes, we’ll discover that each design requires a minimum amount of space.
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
We can also define it on the basis of dp like :
res/layout/main_activity.xml // For handsets
res/layout-sw600dp/main_activity.xml // For 7” tablets(600x1024 mdpi).600dp wide and bigger.
res/layout-sw720dp/main_activity.xml // For 10” tablets (720x1280 mdpi).720dp wide and bigger.
Steps to create Different Screen Layouts :
Step 1 : First go to Android to Project mode in Android studio change at below of the project name.
Step 2 : Create Folders for all screen sizes.
Step 3 : create same xml layout on all these folders.
For Screen Compatibility Issues Try to Use Relative Layout & with Scroll View So To Make your app compatible to Tablet & Horizontal Layout.
I had the same issue and I used this library and it did the thing for me.
The thing is you just have to replace sp with ssp in your xml after adding this library in your gradle and you'll be good to go.
Also for width and height I used this library.
Just replace dp scales with sdp.
I've also answered a question like this here aswel, have a look.

Android - Setting for Tablets

I am pretty new to Android. I wanted to know that if i want to design a tablet application then what changes i want make in the existing code which i designed for normal phone.
I did the Research and found,
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 in Manifest
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Is it all done?? or I want to change something other than this??
You need to create new layout files for tablet versions, Java part is enough but layouts and image drawables are the main things you need.
Go through Supporting Multiple Screens, Here you will have a complete idea about how to create UI supporting Tablets and their res folders.
For all tablet resolutions check this link
below are the available resolutions for android mobile and tablet
1 2560*1600
2 1366*768
3 1280*800
4 1280*768
5 1024*768
6 1024*600
7 960*640
8 960*540
9 854*480
10 800*600
11 800*480
12 800*400
13 640*360
14 640*240
15 480*320
16 400*240
17 320*240
Most Common tablet resolutions are
Samsung Galaxy Tab 10.1 3G - 10.1 inches, 1280 x 800 pixels
Samsung P1000 Galaxy Tab - 7.0 inches, 600 x 1024 pixels
For application to be worked, this is enough. But you should take care the size of the application When you are adding images to drawable folders it will increase your project size. So if you are using same images for all screens put that image in drawable folder. It will pick automatically to all screens, and if you want different image for different screen size put in different layout folders. You can make different layouts according to screen size to be fitted. The android will automatically pickup the proper xml files.
add layout-large-hdpi folder to ur resources and copy the files from layout to created one,
all ur created layouts will automatically converted to tablet screen size

How to have android application support multiple screen sizes with <supports-screens

So I used the following code below to have my application to scale screen size on different android devices but when I am testing on my Nexus 7 its does not scale and its as if it was on a 4 inch screen. When I run it in the emulator on a 7 inch screen it works. Anything wrong with my manifest file?
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:anyDensity="true"
/>
this code goes right before the "application" part right?
Ok, so what you have to know is that support-screens doesn't make your application look 'nice' on screens you are supporting (check this link). It just tells that users with such screens will be able to download your application, but it's up to you to make it display properly. You have to create layouts for specific screens on your own.
More about it you can read in Android's documentation: http://developer.android.com/guide/practices/screens_support.html
Basically, you have to properly name your directories in which layout files are stored in order to let Android know which one should it pick up for specific device. If for example your layout's file was "layout.xml" you should have:
/res/layout/layout.xml // Default layout
/res/layout-small/layout.xml // Small screens
/res/layout-large/layout.xml // Large screens
/res/layout-xlarge/layout.xml // Extra large screens
You can go even further and make also different layouts for portrait and landscape views by specyfing another keyword in directory's name:
/res/layout-small-land/layout.xml // Small screens, landscape view
/res/layout-small-portrait/layout.xml // Small screens, portrait view
Remember that tags order is important, so you can't write layout-portrait-small.
Use Relative layout it will solve most of your problem .Additional use Folder name with given below
the way i am dealing with multiple screen is this way and its working fine.....if any one has improved wayso do guide me
Screen size 480x800
layout-normal-hdpi-480x800
drawable-normal-hdpi-480x800
Screen size Galaxy Nexus--- though its size is 1280x720 but in actual due to system bar its dimension(screen size) differs
layout-normal-xhdpi
drawable-normal-xhdpi
Screen size Note 5.3---
layout-normal-xhdpi-1280x800
drawable-normal-xhdpi-1280x800
Screen size S3---
layout-normal-xhdpi-1280x720
drawable-normal-xhdpi-1280x720
Screen size 7inch tab 2 supporting OS version 3 and above--- dont write dimension 1026x600 bsz in actual due to system bar its dimension(screen size) differs
layout-large-mdpi
drawable-large-mdpi
Screen size 7inch tab p1000 etc supoorting os verion less than 3---
layout-large-hdpi-1024x600
drawable-large-hdpi-1024x600
Screen size 1280x800 tab 10.1,10.2,note 10.1 etc--- you can add dimension if you want other wise it is fine
layout-xlarge-mdpi
drawable-xlarge-mdpi

how can i get my android app to properly display on a touchpad?

i created a game and released it, but really only tested it on phones and the emulator. later on i downloaded it on a touchpad and it confined to a small box at the top. through some searching i found that adding this code to my manifest:
android:resizeable="true"
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="false" />
i got it to fill up the whole screen, but everything is now horrendously out of proportion. is there a better way of going about this? do i need a separate layout xml for phones and touchpads? do i need to rewrite my original xml from the ground up?
Read this article:
http://developer.android.com/guide/practices/screens_support.html
By following the practices described in this document, you can create
an application that displays properly and provides an optimized user
experience on all supported screen configurations, using a single .apk
file.
...
Your application achieves "density independence" when it preserves
the physical size (from the user's point of view) of user interface
elements when displayed on screens with different densities.
Maintaining density independence is important because, without it, a
UI element (such as a button) appears physically larger on a low density
screen and smaller on a high density screen. Such density-related size
changes can cause problems in your application layout and usability.
...
The Android system helps your application achieve density independence
in two ways:
The system scales dp units as appropriate for the current screen density
The system scales drawable resources to the appropriate size, based on
the current screen density, if necessary
I think it is better to design your layout for every screen size and resolutions. It is easy in android. Copy your layout from "layout" folder of resources and paste it in the "layout-land", "layout-xlarge", "layout-xlarge-land" and ... folders and change those settings you need in them.
you can check this link:

Scaling on android devices beyond 480x800

I have a small Android app which works fine on resolutions up to WVGA (480x800), however beyond this the layouts don't scale (for instance for the Galaxy TAB 1024x600) but appear in the top in the middle (with black borders down sides and at bottom). The layouts look fine in Eclipse at these resolutions.
What Am I doing wrong?
Am I missing something in the manifest? Do I need to supply high resolution resources?
Try putting this in your manifest.
<supports-screens android:xlargeScreens="true" />
http://developer.android.com/guide/topics/manifest/supports-screens-element.html#xlarge
putting
<uses-sdk android:minSdkVersion="4" />
In the correct place in my manifest solved the issue. For some reason I had placed it under <application>.
I've created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
Basically, defining your layouts in dp units is not enough if you want your app to fit on all devices and tablets, since there's 4 different "density-buckets". The tool will allow your layouts to be converted into fitting these density buckets.
It will also explain in further detail how to make flexible view components.

Categories

Resources