Android Full screen 처리하는 방식이 바뀌었는지 이전 코드가 Android 11 폰에서 제대로 동작하지 않더라. 아래 Android developer 사이트를 참고하자.
https://developer.android.com/training/system-ui/immersive?hl=ko
https://developer.android.com/guide/topics/display-cutout
YoutActivity.kt
private fun hideSystemUI() {
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
// Shows the system bars by removing all the flags
// except for the ones that make the content appear under the system bars.
private fun showSystemUI() {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
}
themes.xml (아래 코드는 requires API 27)
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
'프로그래밍 > android' 카테고리의 다른 글
[android] 안드로이드 태블릿 구분하기 (feat. 코틀린) (0) | 2021.09.14 |
---|---|
[android] Kotlin ArrayList SharedPreferences json data (feat. Gson) (0) | 2021.08.24 |
[android] Dp to Px, Px to Dp (0) | 2021.06.30 |
[kotlin] android EditText setMaxLength Programmatically (0) | 2021.06.30 |
[android] Google play HostnameVerifier issue (0) | 2021.06.25 |