Skip to content

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

Description

@duzzi

感谢楼主分享。
在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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions