Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
duzzi opened this issue Sep 3, 2021 · 0 comments

Comments

@duzzi
Copy link

duzzi commented Sep 3, 2021

感谢楼主分享。
在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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant