ScreenRecordHelper icon indicating copy to clipboard operation
ScreenRecordHelper copied to clipboard

在全面屏手机调用getDisplayMetrics().heightPixel获取的高度不对

Open duzzi opened this issue 3 years ago • 0 comments

感谢楼主分享。 在Redmi k30 pro测试录屏发现视频左右有黑边,最后定位找到getDisplayMetrics().heightPixel获取到的屏幕高度不对,缺失了几十像素,改成了下面的方法获取屏幕高度:

public static int getScreenHeight() {
    WindowManager wm = (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);
    if (wm == null) return -1;
    Point point = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        wm.getDefaultDisplay().getRealSize(point);
    } else {
        wm.getDefaultDisplay().getSize(point);
    }
    return point.y;
}

duzzi avatar Sep 03 '21 02:09 duzzi