pfoof
pfoof

Reputation: 195

Android "smallest width" layout for tablets not working

I have two activity_menu.xml one for tablets in layout-sw600dp and another in layout. The layout for tablets is never loaded (I even tested it on 4K xxxhdpi emulator). I would also add that all my layouts are portrait. Is there anything that maybe needs to be changed in manifest, gradle or added to a file?

I didn't try layout-large, but I want to keep it "modern", not using deprecated methods.

Upvotes: 1

Views: 364

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006664

The layout for tablets is never loaded (I even tested it on 4K xxxhdpi emulator).

I do not know what you consider 4K to be, as there seem to be multiple definitions.

However, xxxhdpi is 640dpi. 640dp is 2560 pixels at xxxhdpi density. Both 4K definitions cited on Wikipedia have the smallest width as 2160 pixels. Hence, this emulator would not use res/layout-sw640dp/, as it is not big enough.

To create an emulator that will use res/layout-sw640dp/ resources, you need to create one whose smallest width is 640dp or larger. So, for example, if you create an mdpi emulator, where 1dp = 1px, you would need to choose a resolution where both sides are 640px or larger.

Upvotes: 1

Related Questions