Question

I want to have a normal layout for phones and phablets in size 5.99 inch or less and when it becomes 6.0 inch my source of layout folder change.

I have tried layout-large but it contains 5 to 7 inch and xlarge is +7.1. My minimum API is 7.

Was it helpful?

Solution

There is no way to make a cutoff that will cover all 6.0+ inch screens in Android. Android does not distinguish sizes this way.

The most correct way to do what you are trying to do is to use the normal/large/xlarge qualifiers. These will be specified by the device manufacture, so you will be supporting the device with a layout that corresponds to what the manufacturer is expecting. But unfortunately, you will get some 5-7in screens in the large category, but not all. You will get some xlarge vs. large where you might not expect.

You should definitely read Android's guidelines on supporting multiple screen sizes: http://developer.android.com/guide/practices/screens_support.html

Now, if you want more control over when to use your different layout resources, there are some other options. sw<N>dp, w<N>dp, or h<N>dp might work depending on your requirements. Unfortunately for you, these qualifiers were added in API 13. But the good news is that most tablet and phablet devices you are worried about will be 13+, you just have to make sure you can fail over gracefully.

For example, layout-sw600dp should cover most of your 7+in tablets. You can do a smaller dp to try to get your phablets, or a larger one to cover your bigger tablets. You will not be able to specify exactly on 5.99 vs 6.0 in screens since different devices will have different width, height, and pixel densities. But this will get you much closer than normal vs. large.

You can get a comprehensive list of resource qualifiers here: http://developer.android.com/guide/topics/resources/providing-resources.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top