How does Android define a screen resolution as long?

痞子三分冷 提交于 2019-12-01 09:12:45

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!