[안드로이드 스튜디오] - StatusBar & NavigationBar 높이 구하기
2022. 4. 19. 15:39ㆍ모바일/안드로이드
반응형
안드로이드 Resources
status Bar 높이 구하기 1
private fun getStatusBarHeight(): Int {
var result = 0
// val resourceId: Int = this.applicationContext.resources.getIdentifier("status_bar_height", "dimen", "android");
val resourceId: Int = resources.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
// result = this.applicationContext.resources.getDimensionPixelSize(resourceId)
result = resources.getDimensionPixelSize(resourceId)
}
return result
}
status Bar 높이 구하기 2
val statusHeight = getStatusBarHeight()
navigation Bar 높이 구하기 1
private fun getNaviBarHeight(): Int {
var result = 0
// val resources: Resources = this.application.resources
val resourceId: Int = resources.getIdentifier("navigation_bar_height", "dimen", "android")
if (resourceId > 0) {
result = resources.getDimensionPixelSize(resourceId)
}
return result
}
navigation Bar 높이 구하기 2
val naviHeight = getNaviBarHeight()
728x90
반응형
'모바일 > 안드로이드' 카테고리의 다른 글
[안드로이드 스튜디오] - fragment에서 View 애니메이션 구현하기 (0) | 2022.04.19 |
---|---|
[안드로이드 스튜디오] - 무선으로 휴대폰 연결하기 (0) | 2022.04.07 |
[안드로이드 스튜디오] - Fragment로 주간 캘린더 만들기 (0) | 2022.04.05 |
[안드로이드 스튜디오] - 타이틀바 커스텀하기 (0) | 2022.04.03 |