Android Multiple Screen Resolutions - android

I've created a android layout that looks fine on my Galaxy s2 (480×800) device. I want to support a layout for and Galaxy s3 (720x1280) so i created a AVD with those specs, then copied the res/layout directory and contents to two other directories: res/layout, res/layout-large and res/layout-xlarge. To test that the layouts were working positioned a test button at parent-center in res/layout, parent-left in res/layout-large and parent-right in res/layout-xlarge. If i run the application on my device (480×800) or in the AVD (720x1280) the test button is always at parent-center. Why isn't the test button positioned by the values specified in res/layout-large or res/layout-xlarge.
My manifest is as follows:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" />
<supports-screens
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
I am targeting 2.3.3 and have also cleaned my build before testing
Im seriously going mad so any help would be appreciated.

I don't believe the Galaxy S3 is a "large" screen. Small/normal/large/xlarge refer to physical size, not pixels. You need a combination of screen density and screen size to target different devices. Read the Android guides and training for more details on this.

Related

Android single screen layout for all devices

I created an Android app and tested it on Nexus6 Emulator. Everything seems fine on Nexus6 Emulator but when I ran that app on real devices (Samsung S6 and S5) the layout was all messed up. How can I fix this?
Do I have to create separate layout for each device?
Does Android have something like 1 layout for all screens?
I dragged and dropped all images in drawable folder instead of using "add image asset". There is nothing in hdpi, mdpi folder. All images are in drawable folder. Is this the cause of my issues?
Please advise.
It is all about the design of your xml. When designing your pages, try to use 'match parent' and ensure that you are making a layout that fits across all screen resolution. Look into AFAIK...
https://developer.android.com/training/multiscreen/screensizes.html
https://developer.android.com/training/multiscreen/screendensities.html
https://developer.android.com/guide/practices/screens_support.html
How to define dimens.xml for every different screen size in android?
For example:
In your xml
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />

Multiple Screen Support - Android Studio?

I know that i have to put this code in manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
also i created different layout sizes and dimens:
layout-small
layout-normal
layout-large
layout-xlarge
Here is the confusion, the phone will pick automatically the screen size but there are different phone with screen sizes that pick same layout size. Let say layout-normal can take starting galaxy one and S up to galaxy 6 which have different screen size. In layout-normal is only one file but it will not fit all phones which takes layout-normal.
How to design and fix that layout that fixes every screen in layout-normal?

Android layout qualifier does't work

Problem:When I tested my program on different size Android phones, the layout were not selected correctly.
I used setContentView(R.layout.activity_home) to set the layout.
In the res/ directory, I created
res/layout/activity_home.xml
res/layout-sw320dp/activity_home.xml
res/layout-sw480dp/activity_home.xml
res/layout-sw720dp/activity_home.xml
In the AndroidManifest.xml
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:anyDensity="true"
/>
Then I tested it seperately on 320x480,480x800,720x1280 emulators. All these devices selected the layout /res/layout-sw320dp/activity_home.xml.
The target platform I set is 4.4.2 and the emulator's version is 4.3.3.
I have no idea why this happened..
http://developer.android.com/guide/practices/screens_support.html
and
/ here
here
use this link and use the directory structure to support multiple screens
Hope it may help u

Android application for Tablet

I have developed an application that is to be run on android Tablet as well. It is working on android phones perfectly. When I ran it on Tablet, it did not expand on whole screen. It just covered a area equal to a mobile device. I want that it also runs on Tablet and cover the whole screen as running on mobile device. Do I have to create two different designs for each type and at run time before using design, I would have to check it whether it is android phone or table?
Add below code in android manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Add the following block of code in your manifest file after the <uses-sdk>tag:
<supports-screens
android:xlargeScreens="true"
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Note: Add the android:xlargeScreens="true" attribute if and only if your minSdkVersion is equal to or more than 9.
In addition to adding this block of code, follow this link. Also suggest you to go through the following links:
Supporting Multiple Screens
Supporting Different Screen Sizes
Supporting Different Densities
Hope this helps.
please try
<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="11"/>
<supports-screens android:anyDensity="true" />
in Manifest.xml before tag.
I hope it may be help you.
Yes, ideally you'll design layouts targeted to tablets. You don't have to, but you can. See here for details. Your app is running in "screen compatibility mode". See here for info about that.
I think you used fixed width and height for any view or layout in your app, to support a fixed resolution of your mobile device.
If you use fill_parent, wrap_content and weight property, such things in your app, the app will fill entire screen of any android device. Once review your code.
Small example
Assume device has no rotation. Your device has resolution 320 X 240. you have to fill 3 buttons horizontally, you can put each button width=100 and remaining as margin/padding of layout. If you run same app on device with resolution 640 X 480, some space will come after 3 buttons. If you use width=fill_parent and layout_weight=1 for these 3 buttons and parent's layout_width=fill_parent, on any resolution these 3 buttons will fill the entire width of screen.
I hope it may help you.

Android - layout-large folder is been ignored

I have different layout files for
different screens size like
Folder Structure:
layout
layout-large
layout-small
For emulators like HVGA and QVGA there
is no problem, the respective
layout.xml file being refereed. But
the layout-large folder is ignored
when I run the emulator of
WVGA(480x854) , here it is referring
the "layout" folder of the
application. Please point me to the
right direction which is right way to
handle this situation.
I tried using
layout-large-hdpi layout-large-mdpi layout-large-ldpi
layout-normal-hdpi layout-normal-mdpi layout-normal-ldpi
And in the AndroidManifest.xml I
specified
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
but no success
I think the Problem is that people always create a large screen by AVD Manager and it sets the default density to 240 which is not supported by /res/layout-large
If you want to want to test /res/layout-large/any_layout.xml then you should see the density of your virtual device it should be set to 160 not 240 or 120
Make sure the set up emulator's default size is "large" and not "xlarge".
For example if the emulator size is "xlarge", then the "layout-large" folder will be ignored and the default "layout" folder will be used, because it can't find a "layout-xlarge" folder.
This is easy to identify if your using Android Studio.
Have you checked if your API Level is already supporting this? I had this issue as well. In my case I used following line in the manifest, which set the TargetSDK to 4 (1.6), where the support of those different layouts started.
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
Links:
Screen Support

Categories

Resources