최종수정 : 2022.03.21
fun checkDisplaySize(ctx: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val metrics = windowManager.currentWindowMetrics
val bounds: Rect = metrics.bounds
val legacySize = Size(bounds.width(), bounds.height())
println("gimgongta log width : ${legacySize.width}, height : ${legacySize.height}")
} else {
val outMetrics = DisplayMetrics()
val display: Display
@Suppress("DEPRECATION")
display = (ctx as Activity).windowManager.defaultDisplay
@Suppress("DEPRECATION")
display.getMetrics(outMetrics)
val size = Point()
@Suppress("DEPRECATION")
display.getRealSize(size)
println("gimgongta log width : ${size.x}, height : ${size.y}")
}
}
디바이스 전체 화면의 크기이다.
상단이나 하단의 바들도 포함된 크기이다.
[Android][ADB] 안드로이드 기본 adb 위치 (0) | 2022.03.23 |
---|---|
[Android][Kotlin] 안드로이드 디바이스 DPI 구하기 (0) | 2022.03.23 |
[Android] xml drawable 파일 특정 stroke 테두리 제거 (0) | 2022.01.11 |
[Android] Command line is too long. Shorten command line for ExampleUnitTest or also for Android JUnit default configuration. 에러 해결법 (0) | 2021.12.31 |
[Android][Kotlin] 안드로이드 벨소리 울리기 (0) | 2021.11.17 |
댓글 영역