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());
|
}
|
|
}
|