xdpi layout and hdpi layout - android

When I try to run my app in the emulator with a large res (1280x800) the xdpi layout should be inflated - but instead the hdpi layout is inflated.
why is that happen?
how can i force android to inflate the correct one?
edit:
layout-large/main.xml
layout-xlarge/main.xml
thanks in advance

if your avd details is showing hw.lcd.density as 320 mean it will pick from xhdpi
if hw.lcd.density: 240 then it will pick from hdpi
//you need to do like this:
layout-hdpi //this is wrong
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

Related

Displaying views according to screen size

When you are displaying views according to dp scale, it means that they are displayed the same physical size at any device... Which means that the display might seem a little emptier at bigger screens right?
Then How do you display views according to the screen sizes?
For different screen size, Use different Layout and different image
This linke is good Supporting Multiple Screens | Android Developers
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

application layout not supporting with smaller screen size tablet

I have created an application for 10" tablet and set the layout related to screen size but my application is not supported with 7" tablet though i design folder in resource as
res/layout-w320dp
res/layout-w600dp
res/layout-w720dp
so please tell me how to set with other screen sizes.
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
For further reference check here: http://developer.android.com/guide/practices/screens_support.html

layout for multiple DPI and SIZE screens in android

how am i refer a layout in res library for differnt screens (DPI and SIZE)?
can i do this in re folder:
layout-mdpi-xlarge
layout-mdpi-normal
layout-xhdpi-large
and so on...
http://developer.android.com/guide/practices/screens_support.html
You can find an answer to your question by going through the link in detail.
See the topic under Using configuration qualifiers especially the section under table1.
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
For drawables.
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

different layout parameters for different devices

I have created a layout in my xml file and have a LinearLayout that is displayed at the top of the activity. I have set its width to fill_parent and its height to 54dp. The height of the layout looks good on devices with bigger screens like Samsung Galaxy, but on smaller devices it looks too big. Is there anyway that the layout will have different height on different screen sizes? I am guessing that this might be achieved by dp, dip, etc. but I'm not sure as to what exactly they do
make layout-normal-hdpi, layout-normal-mdpi and layout-normal-xhdpi folders and copy the same xml in all the three folders than set the different height on each xml as per the devices. This is the standard technique which is been followed. Try this you will surely get desired result.
Hope this will help 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
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Low density Small screens QVGA 240x320
res/layout-small-ldpi
res/layout-small-land-ldpi
Low density Normal screens WVGA400 240x400 (x432)
res/layout-ldpi
res/layout-land-ldpi
Medium density Normal screens HVGA 320x480
res/layout-mdpi
res/layout-land-mdpi
Medium density Large screens HVGA 320x480
res/layout-large-mdpi
res/layout-large-land-mdpi
High density Normal screens WVGA800 480x800 (x854)
res/layout-hdpi
res/layout-land-hdpi
Xoom (medium density large but 1280x800 res)
res/layout-xlarge
res/layout-xlarge-land
Comment me for any query...

layout-large-land-hdpi error

I'm trying to use inside res the folder
layout-large-land-hdpi
but the sdk gives me an error and does not compile.
layout-large-hdpi works!
As it says here, it should work!
//yes we can use either layou-large and layout-large-mdi and so..
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
Low density Small screens QVGA 240x320
res/layout-small-ldpi
res/layout-small-land-ldpi
Low density Normal screens WVGA400 240x400 (x432)
res/layout-ldpi
res/layout-land-ldpi
Medium density Normal screens HVGA 320x480
res/layout-mdpi
res/layout-land-mdpi
Medium density Large screens HVGA 320x480
res/layout-large-mdpi
res/layout-large-land-mdpi
High density Normal screens WVGA800 480x800 (x854)
res/layout-hdpi
res/layout-land-hdpi
Xoom (medium density large but 1280x800 res)
res/layout-xlarge
res/layout-xlarge-land

Categories

Resources