tho*_*oud 4 android android-fragments
我正在看这篇文章: 当我在片段类中尝试确定设备屏幕的大小时,获取屏幕尺寸(以像素为单位).一个答案接近我需要的但是最终为我工作的唯一代码是:
WindowManager wm = (WindowManager) getView().getContext().getSystemService(Context.WINDOW_SERVICE);
Display screen = wm.getDefaultDisplay();
Run Code Online (Sandbox Code Playgroud)
然后我可以使用getHeight(); 或其他未弃用的术语.