Android - layout-large folder is been ignored - android

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

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" />

Screen Resolution for different Android Devices [duplicate]

This question already has answers here:
Application Skeleton to support multiple screens
(2 answers)
Closed 9 years ago.
How to Solve Screen Resolution Problem?
I want my application run on any android device, and its layout should not change,
I read android Blog of Supporting Multiple Screens,But do not get enough idea.
I have created different layout folder like layout-small,layout-normal,layout-large,layout-xlarge and created different XML files for all folder.
But when i run on Tablet it takes Default normal size XML file,I don't know why?
Please help me to solve it, Thanks in advance and Waiting for response
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
Add this to your manifest file of app.
Create the layout and drawable with following qualifiers
layout-sw600dp drawable-sw600dp
which means tablet screen with minimum of 600dp and higher can use this layout and drawable.
So for standard configuration qualifiers for screen size you can create following configuration:
1)layout-sw480dp drawable-sw480dp
2)layout-sw600dp drawable-sw600dp
3)layout-sw720dp drawable-sw720dp
check http://android-developers.blogspot.in/2011_07_01_archive.html
Following the guide will only help you to deal the problem for the most cases, but never all the scenarios. Check the following list which is the Google's AOSP homescreen source code. Even this cannot guarantee it will work for all the devices. So yours are far from enough.
drawable
drawable-hdpi
drawable-land-hdpi
drawable-land-mdpi
drawable-land-xhdpi
drawable-mdpi
drawable-nodpi
drawable-sw600dp-hdpi
drawable-sw600dp-land-hdpi
drawable-sw600dp-land-mdpi
drawable-sw600dp-mdpi
drawable-sw600dp-nodpi
drawable-sw600dp-xhdpi
drawable-sw720dp-hdpi
drawable-sw720dp-land-hdpi
drawable-sw720dp-land-mdpi
drawable-sw720dp-mdpi
drawable-sw720dp-nodpi
drawable-sw720dp-xhdpi
drawable-xhdpi
layout
layout-land
layout-port
layout-sw600dp-port
layout-sw720dp
layout-sw720dp-port
According to this page the layout-small,layout-normal,layout-large,layout-xlarge
are deprecated and you will use the
36x36 for low-density
48x48 for medium-density
72x72 for high-density
96x96 for extra high-density
as alernative, however for further information please check my answer here

how to include a layout for 7 inch tablet?

I'm new to android.I have layout-sw600dp/home.xml for tablets, but it does'nt fit to it. It uses home.xml from normal Layout folder.
Please help me to fit the screen to 7 inches tablet.
layout-sw600dp is the right way to do this.
layout-xhdpi has nothing to do with tablets and layout-large is deprecated in favor of layout-sw600dp .
The problem might come from your tablet, is it a bit smaller than 7" ? if you try layout-sw500dp, does it still use the same default file ?
If you want to fit your device (BSNL Penta is701c) try layout-large-mdpi or layout-large-ldpi, because your device have very small resolution (800*480) for 7''.
But normally you should use layout-sw600dp for 7'' devices.
try to add this to your app manifest :
<manifest ... >
<supports-screens android:requiresSmallestWidthDp="600" />
...
</manifest>

Android Multiple Screen Resolutions

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.

Android- Providing Alternative Resources not working?

I feel as if I'm missing something.
In my application, I decided to provide alternative drawable resources and alternative layout files. My structure is as follows:
res/drawable-hdpi/filename.png
res/drawable-mdpi/filename.png
res/drawable-ldpi/filename.png
res/layout-small/layout.xml
res/layout-large/layout.xml
res/layout/layout.xml
I created three different emulators: one with the default HVGA, one with QVGA, and one with WVGA800
It doesn't seem to pick up those alternative resources/layouts based on screen size/density, or maybe i just can't tell?
Is there some way, other than using a device for each specific size, to test this? Or am I just missing something important?
Another question, how well does Android scale drawables if no alternative resource exist?
A few points, in no particular order:
Layouts are related to screen size and thus to large, medium, small and drawables are related to density and thus to hdpi,mdpi,ldpi. It is obvious to some and not so easy to understand to others.
Read through this and create your emulator devices as specified in this page, double check to ensure you got them right.
Now start with just a simple layout and test it on the default device skin, then add layout-320x480, test, repeat for other sizes. If you are using layout-large/small etc, remember to add the correct lines to AndroidManifest.xml <supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizable="true"
android:anyDensity="true" />
One simple way to do this is to have a default layout.xml and drawables folder, and for different sizes have layout-320x480.xml etc folders and different densities we have drawables-hdpi etc folders. If you make sure to set android:anyDensity="false" /> in manifest file then the handset will get correct layouts and assets depending on its attributes.
If you set android:anyDensity="false" /> in manifest file the handset handles the sizing of drawables, typically taking assets from drawables folder and resizing it.
In 3.2 above version android developer have been released two new things for tablets
layout-sw600dp-land
layout-sw720-land

Categories

Resources