原创文章,禁止复制,需要引用需指定原文。
只有activity可以使用WindowManager,否则应该使用Context.getResources().getDisplayMetrics()来获取。
Activity中设置DM:
DisplayMetrics dm =newDisplayMetrics();
WindowManager manager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
manager.getDefaultDisplay().getMetrics(dm);
手机屏幕参数与实际屏幕参数是不一样的。
Context.getResources().getDisplayMetrics()依赖于手机系统,获取到的是系统的屏幕信息;
WindowManager.getDefaultDisplay().getMetrics(dm)是获取到Activity的实际屏幕信息。
分析:
manager.getDefaultDisplay().getMetrics(dm)---app的:
/** * Gets display metrics that describe the size and density of this display. * <p> * The size is adjusted based on the current rotation of the display. * </p><p> * The size returned by this method does not necessarily represent the * actual raw size (native resolution) of the display. The returned size may * be adjusted to exclude certain system deco

522

被折叠的 条评论
为什么被折叠?



