Dan
Dan

Reputation: 2344

Defining a different XML layout depending on the device/screen size?

I have read lots of post on this forum and others about using a different layout depending on the device being used.

Below is a screenshot of my layout folder at the moment:

Layout folder

Now, I have tried many different variations to try and get the XML layout to change. The project is designed using a phone and I'm now testing on a 10.1 inch Samsung Galaxy tablet.

Despite all those layouts my app still uses the default .xml file.

Any ideas where I'm going wrong or other variations to try?

I should say I lock the user into portrait mode hence a few layouts with -port.

Any help would be great

thanks

Upvotes: 0

Views: 940

Answers (1)

Tushar Gupta
Tushar Gupta

Reputation: 1410

You need to have your layout-large, layout-sw400dp-port,... folders at the same level as your layout folder instead of having them inside the layout folder. Your folder structure should look like -

/res/layout/
/res/layout-large/
/res/layout-sw400dp-port/main.xml 
...

Upvotes: 5

Related Questions