zhangzengfei
2022-01-10 4496b59ab27d569df1da7ef634e02273b3a9618a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.basic.security.utils;
 
import android.util.DisplayMetrics;
import android.view.Display;
 
import com.basic.security.base.BaseApplication;
 
public class SizeUtil {
 
    static int width = -1;
    static int height = -1;
 
    //    static int width = 2560;
//    static int height = 1440;
    public static float size() {
        Display display = BaseApplication.getApplication().activity.getWindowManager().getDefaultDisplay();
        DisplayMetrics outMetrics = new DisplayMetrics();
        display.getRealMetrics(outMetrics);
 
        float density = BaseApplication.getApplication().activity.getResources().getDisplayMetrics().density;
        float dpHeight = outMetrics.heightPixels / density;
        float dpWidth = outMetrics.widthPixels / density;
        width = outMetrics.widthPixels;
        height = outMetrics.heightPixels;
        return (float) ((dpHeight / dpWidth) / (1536.0 / 2048.0));
    }
 
    public static int toolbarHeight() {
        return (int) ((85.0 / height1()) * height());
    }
 
    public static int w(int w) {
        return (int) ((((double) w) / width1()) * width());
    }
 
    public static int h(int h) {
        return (int) ((((double) h) / height1()) * height());
    }
 
    public static int h1(int h) {
        return (int) ((((double) h) / height1()) * height() * width1() / width());
    }
 
//    public static void main(String[] args) {
//    }
 
    public static int height() {
        if (height <= 0) {
            size();
        }
        return height;
    }
 
    public static int height1() {
        return 1536;
    }
 
 
    public static int width() {
        if (width <= 0) {
            size();
        }
        return width;
    }
 
    public static int width1() {
        return 2048;
    }
 
    public static int manage_btn_width() {
        return (int) ((240.0 / width1()) * width());
    }
 
    public static int gap_width() {
        return (int) ((40.0 / width1()) * width());
    }
 
    public static int padding_width() {
        return (int) ((37.0 / width1()) * width());
    }
 
}