«   2026/09   »
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
Archives
Today
Total
«   2026/09   »
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
Archives
Today
Total
관리 메뉴

DBILITY

WindowMetrics 화면 크기 등 본문

android/java

WindowMetrics 화면 크기 등

DBILITY 2024. 5. 4. 22:07
반응형
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
    WindowMetrics windowMetrics = getWindowManager().getCurrentWindowMetrics();
    Log.e(TAG, windowMetrics.getBounds().width() + " : " + windowMetrics.getBounds().height());
} else {
    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    display.getRealMetrics(displayMetrics);
    Log.e(TAG, displayMetrics.widthPixels + " : " + displayMetrics.heightPixels);
}
반응형
Comments