开发者

How does Android define a screen resolution as long?

With Androi开发者_运维百科d, you can define different resources for different phone attribute by naming res directories appropriately. I need to be able to support different layouts for 480x800 and 480x854. I figured I could have one set of resources stored in the layout-hdpi-v4 directory and another in layout-long-hdpi-v4. However, both resolution seem to think that they are long (at least based on the emulator, which I understand may not reflect devices accurately).

Is there another way in which I can distinguish between the two resolutions/aspect ratios?


There is a screen size qualifier, though its use is deprecated and recommended to not be used:

layout-800x480,layout-854x480

Otherwise, it doesn't look like there is a supported way in resource naming that can differentiate the two resolutions, besides using flexible layouts to expand into the extra screen space.


If you want to determine the screen size in code, DisplayMetrics will help

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

You can look at the fields widthPixels and heightPixels.

However, read too the Best Practices for Screen Independence.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜