Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
464 views
in Technique[技术] by (71.8m points)

screen - Android resource notlong / long identifiers not working

Currently I have the following resource folders:
1. layout-sw600dp
2. layout-sw600dp-notlong

The idea is that we have 3 types of devices and the devices should use the resources from the correct folder accordingly. The devices are:
1. Samsung Galaxy Tab 10.1, 1280 X 800 mdpi. 16/10
2. Asus Transformer TFT 101, 1280 X 800 mdpi. 16/10.
3. A generic tablet, 800 X 600 ldpi. 4/3.

The problem is that all 3 devices use resources from layout-sw600dp-notlong. To my understanding 4/3 is categorized as -notlong devices.

Is there anything wrong in my identifier usage? Or there's a bug reported for the identifier?

Thank in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

According to the source code. (framework/base/core/java/android/content/res/Configuration.java)

        // Is this a long screen?
        if (((longSizeDp*3)/5) >= (shortSizeDp-1)) {
            // Anything wider than WVGA (5:3) is considering to be long.
            screenLayoutLong = true;
        } else {
            screenLayoutLong = false;
        }

So if the aspect ratio is wider than 3:5(or 1.667), it will be treated as long screen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...