반응형
안드로이드에서 다크모드, 라이트모드 혹은 임의 지정한 Status Bar 색상에 따라 상태바 내의 글씨가
보이지 않는 경우가 있습니다. 이 문제를 해결하기 위한 방법을 알아보도록 하겠습니다.
<xml 코드>
<item name="android:windowLightStatusBar">true</item>
위 코드를 res/values/theme.xml 에 추가하면 됩니다.
(단, 해당 코드는 안드로이드 API 23 이상 부터 사용할 수 있으며,
windowLightStatusBar 값이 true는 라이트모드, false일 경우 다크모드 시에 사용합니다 )
<소스 코드>
// API 30부터 deprecated됨 (API 30 이전)
// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
// 대체 코드 (API 30 이후)
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightStatusBars = true
기존에는 window.decorView.systemUiVisibility()를 이용해서 해결할 수 있었지만, 해당 메소드는 안드로이드 API 30 부터
deprecated 되었습니다.
API 30이상 부터는 WindowInsetsControllerCompat을 이용하면 해결할 수 있습니다.
<참고자료>
https://stackoverflow.com/questions/42789789/set-windowlightstatusbar-property-programmatically
set windowlightstatusbar property programmatically
As you know we can set the windowLightStatusBar from xml by following codes. true i need to change this attribute true to false or fal...
stackoverflow.com
반응형
'Android' 카테고리의 다른 글
[안드로이드 / Kotlin] startActivityForResult 대체 (0) | 2021.09.05 |
---|---|
[안드로이드 / Kotlin] 코드로 문자열 밑줄 표현하기 (0) | 2021.09.04 |
[안드로이드 / Kotlin] 뒤로가기 두번 눌러서 종료하기 (0) | 2021.08.31 |
[안드로이드 / Kotlin] Array와 ArrayList 변환 (0) | 2021.08.31 |
[안드로이드 / Kotlin] 라디오버튼 Dialog (0) | 2021.08.31 |