LemonITCN / LemonHello4Android

妈妈说,问人问题要先说你好,那么咱这个全平台的理论上做的最牛逼的对话框(只是理论上)就叫LemonHello吧~
MIT License
229 stars 51 forks source link

Fragment页尺寸获取不正常问题 #17

Open 992480014qq opened 5 months ago

992480014qq commented 5 months ago

解决方法 在LemonHelloPrivateSizeTool.java文件里

void setContext(Context context) {
    _metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    if (windowManager != null) {
        Display display = windowManager.getDefaultDisplay();
        if (display != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                display.getRealMetrics(_metrics);
            } else {
                display.getMetrics(_metrics);
            }
            _density = context.getResources().getDisplayMetrics().density;
        }
    }
}