Qasim
Qasim

Reputation: 5321

How to Define Layouts for Landscape Orientation in Android?

How do i define folder structure for layout resources in Android project, i know that there's generic folder structure like:

But i wanna define separate landscape folders for my xhdpi and xxhdpi as well?

I'm ubable to use layout-land-xhdpi for my landscape resources, moreover android studio preview is also not picking up layout resources from layout-land-xhdpi?

Upvotes: 1

Views: 1510

Answers (3)

Qasim
Qasim

Reputation: 5321

I've used the following qualifiers for xhdpi and xxhdpi devices and working fine for me, Secondly if android studio is not picking the right layouts in designer preview then try clearing the cache, cleaning the project or even restarting android studio will surely solves your problem.

layout-land-xhdpi
layout-land-xxhdpi

Upvotes: 2

Rameesh
Rameesh

Reputation: 31

I do not agree with the above answer. Resources can be organized in various ways If you are using xlarge,xlarge-land etc you are organizing them according to screen size or screen resolution (WXGA etc) But if you use xhdpi,xxhdpi etc you are organizing according to screen density. So it is your wish how you want to organize your resources both are valid ways and have own use case scenario's. If resources are not reflecting then either you are not using the device of that appropriate screen density (xxhdpi etc) while verifying or you have declared android:configChanges="orientation|screenSize" in your manifest which will disallow activity to use landscape mode layouts by calling onCreate() again.

Upvotes: 2

Booger
Booger

Reputation: 18725

You are not using the correct qualifiers - it should be large, xlarge, xlarge-land, etc and NOT XXHDPI, etc:.

Here is the list of qualifiers (from the docs) as they are designed to work:

res/layout/my_layout.xml              // layout for normal screen size ("default")
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/graphic.png         // bitmap for medium-density
res/drawable-hdpi/graphic.png         // bitmap for high-density
res/drawable-xhdpi/graphic.png        // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png       // bitmap for extra-extra-high-density

res/mipmap-mdpi/my_icon.png         // launcher icon for medium-density
res/mipmap-hdpi/my_icon.png         // launcher icon for high-density
res/mipmap-xhdpi/my_icon.png        // launcher icon for extra-high-density
res/mipmap-xxhdpi/my_icon.png       // launcher icon for extra-extra-high-density
res/mipmap-xxxhdpi/my_icon.png      // launcher icon for extra-extra-extra-high-density

That doc is a MUST read for supporting multiple screens, I would review it (it will save you lots of time)

Upvotes: 2

Related Questions