๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[Android] ์‹œ์Šคํ…œ ๋ฐ” ์ œ์–ด

decor view์˜ ์“ฐ์ž„์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋‹ค๊ฐ€ ์‹œ์Šคํ…œ ๋ฐ” ์ œ์–ด๋ฅผ ๋ณด๊ฒŒ ๋๋‹ค.

 

์‹œ์Šคํ…œ ๋ฐ”๋Š” ๋ฌด์—‡์„ ์˜๋ฏธํ•˜๋‚˜

https://developer.android.com/training/system-ui

 

์‹œ์Šคํ…œ UI ๊ณต๊ฐœ ์ƒํƒœ ์ œ์–ด  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

์‹œ์Šคํ…œ UI ๊ณต๊ฐœ ์ƒํƒœ ์ œ์–ด ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ๊ทธ๋ฆผ 1. [1] ์ƒํƒœ ํ‘œ์‹œ์ค„ ๋ฐ [2] ํƒ์ƒ‰ ๋ฉ”๋‰ด๊ฐ€ ํฌํ•จ๋œ ์‹œ์Šคํ…œ ํ‘œ์‹œ์ค„ ์‹œ์Šคํ…œ ํ‘œ์‹œ์ค„์€

developer.android.com

 

The system bars are screen areas dedicated to the display of notifications, communication of device status, and device navigation. Typically the system bars (which consist of the status and navigation bars, as shown in figure 1) are displayed concurrently with your app.

๋ฐœ๋ฒˆ์—ญ

์‹œ์Šคํ…œ ๋ฐ”๋Š” ์•Œ๋ฆผ ๋…ธ์ถœ, ๋‹จ๋ง์˜ ํ†ต์‹  ์ƒํƒœ, ๋‹จ๋ง ํƒ์ƒ‰์˜ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์Šคํฌ๋ฆฐ ์˜์—ญ๋“ค์ž…๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ์‹œ์Šคํ…œ ๋ฐ”๋Š” (์ƒํƒœ๋ฐ”, ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ”๋ฅผ ํฌํ•จํ•ด์„œ, ๊ทธ๋ฆผ 1์—์„œ ๋ณด๋“ฏ์ด) ์•ฑ์— ๋™์‹œ์— ๋…ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

 

๊ทธ๋ฆผ1. 1๋ฒˆ์ด ์ƒํƒœ๋ฐ”, 2๋ฒˆ์ด ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ”. https://developer.android.com/training/system-ui

 

๊ณต์‹๋ฌธ์„œ์—์„œ ์ •์˜ํ•ด์คŒ. ์ผ๋ฐ˜์ ์œผ๋กœ

์‹œ์Šคํ…œ ๋ฐ” = ์ƒํƒœ ๋ฐ” + ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ”

 

์ด๋ฆฌ ์ €๋ฆฌ ์ฝ”๋“œ๋“ค์„ ์‚ดํ”ผ๋‹ค๊ฐ€, WindowInsetCompat.Type์„ ์ ‘ํ–ˆ๋‹ค. WindowInsetsCompat.Type์—์„œ systmeBars() ๋ผ๋Š” ๋ฉ”์†Œ๋“œ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค. ์ด๋ ‡๊ฒŒ API์—์„œ ์‹œ์Šคํ…œ ๋ฐ”๋ผ๊ณ  ์ •ํ•ด์ค€ ๊ฒƒ์ด ๋ฌด์—‡์ธ์ง€ ํ™•์ธํ•ด๋ณด์•˜๋‹ค.

WindowInsetsCompat.Type.systemBars()

์ƒํƒœ ๋ฐ”์™€ ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ”๋Š” ๋‹น์—ฐํžˆ ์žˆ์„ ๊ฒƒ์„ ์•Œ์•˜๋Š”๋ฐ, ์บก์…˜ ๋ฐ”๋ผ๋Š” ๊ฒƒ๋„ ์‹œ์Šคํ…œ ๋ฐ”์— ์†ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ์•˜๋‹ค. ๊ทธ๋ž˜์„œ ์บก์…˜ ๋ฐ”๊ฐ€ ๋ฌด์—‡์ธ๋ฐ? ์ž๋ง‰์ด์—ˆ๋‹ค. 

 

์•ˆ๋“œ๋กœ์ด๋“œ ์œˆ๋„์šฐ ์ชฝ์—์„œ ์ฝ”๋“œ ์ƒ ๊ตฌ๋ถ„๋œ ํƒ€์ž…์œผ๋กœ 

์‹œ์Šคํ…œ ๋ฐ” = ์ƒํƒœ ๋ฐ” + ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” + ์ž๋ง‰ ์˜์—ญ

 

์‹œ์Šคํ…œ ๋ฐ” ํ๋ฆฌ๊ฒŒ ๋งŒ๋“ค๊ธฐ

์‹œ์Šคํ…œ ๋ฐ” ํ๋ฆฌ๊ฒŒ ๋งŒ๋“ค๊ธฐ - Android R(API Level 30) ๋ฏธ๋งŒ

https://developer.android.com/training/system-ui/dim

 

์‹œ์Šคํ…œ ํ‘œ์‹œ์ค„ ํ๋ฆฌ๊ฒŒ ํ•˜๊ธฐ  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

์‹œ์Šคํ…œ ํ‘œ์‹œ์ค„ ํ๋ฆฌ๊ฒŒ ํ•˜๊ธฐ ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ์ด ๊ณผ์ •์—์„œ๋Š” Android 4.0(API ์ˆ˜์ค€ 14) ์ด์ƒ์—์„œ ์‹œ์Šคํ…œ ํ‘œ์‹œ์ค„(์ฆ‰, ์ƒํƒœ ํ‘œ์‹œ์ค„ ๋ฐ

developer.android.com

decorView์˜ setSystemUiVisibility()์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ View.SYSTEM_UI_FLAG_LOW_PROFILE๋กœ ๋„ฃ์–ด์ค€๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

fun turnOnOffDimSystemBar() {
	if (requireActivity().window.decorView.systemUiVisibility != View.SYSTEM_UI_FLAG_LOW_PROFILE) {
        // dim ์ฒ˜๋ฆฌํ•˜๊ธฐ
        requireActivity().window.decorView.systemUiVisibility =
            View.SYSTEM_UI_FLAG_LOW_PROFILE
    } else {
        // ์›๋ž˜ ์ƒํƒœ๋กœ ๋ณต๊ตฌํ•˜๊ธฐ
        requireActivity().window.decorView.systemUiVisibility =
            View.SYSTEM_UI_FLAG_VISIBLE
            // View.SYSTEM_UI_FLAG_VISIBLE = 0 ๊ฐ’์ž„
    }
}

 

์‹œ์Šคํ…œ ๋ฐ” ํ๋ฆฌ๊ฒŒ ๋งŒ๋“ค๊ธฐ - Android R ์ด์ƒ

https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_LOW_PROFILE
 

View  |  Android Developers

 

developer.android.com

 

View.SYSTEM_UI_FLAG_LOW_PROFILE์™€ View.setSystemUiVisibility()๊ฐ€ deprecated ๋๋‹ค.

 

deprecated ๋œ ์‹œ์Šคํ…œ ๋ฐ” ๋”ค ์ฒ˜๋ฆฌ. https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_LOW_PROFILE

 

Dim ์ฒ˜๋ฆฌ ํ•  ๋ฐ”์— ์•„์˜ˆ ์‹œ์Šคํ…œ ๋ฐ”๋ฅผ ์ˆจ๊ฒจ๋ฒ„๋ฆฌ๋ผ๊ณ  ํ•œ๋‹ค. ์ด๊ฑด ๋ฐ‘์—์„œ ์‚ดํŽด๋ณธ๋‹ค.

 

์ƒํƒœ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ

์ƒํƒœ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ - Android 4.0 ์ดํ•˜

https://developer.android.com/training/system-ui/status#40
 

์ƒํƒœ ํ‘œ์‹œ์ค„ ์ˆจ๊ธฐ๊ธฐ  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

์ƒํƒœ ํ‘œ์‹œ์ค„ ์ˆจ๊ธฐ๊ธฐ ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ์ด ๊ณผ์ •์—์„œ๋Š” ๋‹ค๋ฅธ ๋ฒ„์ „์˜ Android์—์„œ ์ƒํƒœ ํ‘œ์‹œ์ค„์„ ์ˆจ๊ธฐ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

developer.android.com

Android 4.0์€ 2011๋…„์— ๊ณต๊ฐœ๋˜์—ˆ๋‹ค๊ณ . ๊ตฌ์ง€ Android 4.0 ์ดํ•˜ ๋‹จ๋ง์˜ ๊ตฌํ˜„์„ ๊ณต๋ถ€ํ•  ํ•„์š”๋Š” ์—†๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ ๋‹ค. ์Šคํ‚ต.

 

์ƒํƒœ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ - Android 4.1 ์ด์ƒ ~ Android R(11) ๋ฏธ๋งŒ

 

์ƒํƒœ ํ‘œ์‹œ์ค„ ์ˆจ๊ธฐ๊ธฐ  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

์ƒํƒœ ํ‘œ์‹œ์ค„ ์ˆจ๊ธฐ๊ธฐ ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ์ด ๊ณผ์ •์—์„œ๋Š” ๋‹ค๋ฅธ ๋ฒ„์ „์˜ Android์—์„œ ์ƒํƒœ ํ‘œ์‹œ์ค„์„ ์ˆจ๊ธฐ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

developer.android.com

decorView์˜ setSystemUiVisibility()์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ View.SYSTEM_UI_FLAG_FULLSCREEN์œผ๋กœ ๋„ฃ์–ด์ค€๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

fun hideOrShowStatusBar() {
    if (requireActivity().window.decorView.systemUiVisibility != View.SYSTEM_UI_FLAG_FULLSCREEN) {
    // ํ˜น์€ 
    // if (requireActivity().window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) ์‚ฌ์šฉ
        // ์ˆจ๊ธฐ๊ธฐ
        requireActivity().window.decorView.systemUiVisibility =
                        View.SYSTEM_UI_FLAG_FULLSCREEN
                        // or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        // ์ด ํ”Œ๋ž˜๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์ƒํƒœ๋ฐ”๊ฐ€ ์‚ฌ๋ผ์ง€๋Š” ๊ฒƒ์ด ์ž์—ฐ์Šค๋Ÿฌ์› ๋‹ค.
    } else {
        // ๋ณด์ด๊ฒŒ ํ•˜๊ธฐ
        requireActivity().window.decorView.systemUiVisibility =
            View.SYSTEM_UI_FLAG_VISIBLE
            // View.SYSTEM_UI_FLAG_VISIBLE = 0 ๊ฐ’์ž„
    }
}

 

์ƒํƒœ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ - Android R(11) ์ด์ƒ

https://developer.android.com/develop/ui/views/layout/immersive#type
 

Hide system bars for immersive mode  |  Android Developers

Some content is best experienced in fullscreen without any indicators on the status bar or the navigation bar. Some examples are videos, games, image galleries, books, and presentation slides. This is referred to as immersive mode. This page shows how you

developer.android.com

WindowInsetsControllerCompat.hide()์— WindowInsetsCompat.Type.statusBars()๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋„ฃ์–ด์„œ ์“ฐ๋ฉด ๋œ๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

fun hideOrShowStatusBarOverAndroidR() {
    val windowInsetsController = WindowCompat.getInsetsController(
        requireActivity().window,
        requireActivity().window.decorView
    )
    
    requireActivity().window.decorView.setOnApplyWindowInsetsListener { view, windowInsets ->
        if (windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) {
            windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())
        } else {
            windowInsetsController.show(WindowInsetsCompat.Type.statusBars())
        }
        view.onApplyWindowInsets(windowInsets)
    }
}

 

๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ

๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ - Android R(11) ๋ฏธ๋งŒ

๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋ณด๋‹ˆ ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ ๊ธฐ๋Šฅ์€ Android 4.0, 4.1 ๋•Œ ์ฆˆ์Œ๋ถ€ํ„ฐ ๋“ฑ์žฅํ•œ ๋“ฏ ํ•˜๋‹ค. Andriod 4.0์ด ๋“ฑ์žฅํ•œ ์ง€ 10๋…„์ด ์ง€๋‚ฌ์œผ๋‹ˆ, Android R ๋ฏธ๋งŒ์˜ ๊ตฌํ˜„ ๋ฐฉ๋ฒ•์ด๋ผ๊ณ ๋งŒ ์—ฌ๊ฒจ๋„ ๋  ๋“ฏ ํ•˜๋‹ค.

https://developer.android.com/training/system-ui/navigation 

 

ํƒ์ƒ‰ ๋ฉ”๋‰ด ์ˆจ๊ธฐ๊ธฐ  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

ํƒ์ƒ‰ ๋ฉ”๋‰ด ์ˆจ๊ธฐ๊ธฐ ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ์ด ๊ณผ์ •์—์„œ๋Š” Android 4.0(API ์ˆ˜์ค€ 14)์— ๋„์ž…๋œ ํƒ์ƒ‰ ๋ฉ”๋‰ด๋ฅผ ์ˆจ๊ธฐ๋Š” ๋ฐฉ๋ฒ•์— ๊ด€ํ•ด ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

developer.android.com

decorView์˜ setSystemUiVisibility()์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ View.SYSTEM_UI_FLAG_HIDE_NAVIGATION์œผ๋กœ ๋„ฃ์–ด์ค€๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์— ์ž‘์„ฑํ–ˆ๋‹ค.

fun hideOfShowNavigationBar() {
    if (requireActivity().window.decorView.systemUiVisibility != View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {
    // ํ˜น์€
    // if (requireActivity().window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
        requireActivity().window.decorView.systemUiVisibility =
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    } else {
        requireActivity().window.decorView.systemUiVisibility =
            View.SYSTEM_UI_FLAG_VISIBLE
            // View.SYSTEM_UI_FLAG_VISIBLE = 0 ๊ฐ’์ž„
    }
}

 

๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ - Android R(11) ์ด์ƒ

https://developer.android.com/develop/ui/views/layout/immersive#type

 

Hide system bars for immersive mode  |  Android Developers

Some content is best experienced in fullscreen without any indicators on the status bar or the navigation bar. Some examples are videos, games, image galleries, books, and presentation slides. This is referred to as immersive mode. This page shows how you

developer.android.com

WindowInsetsControllerCompat.hide()์— WindowInsetsCompat.Type.navigationBars()๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋„ฃ์–ด์„œ ์“ฐ๋ฉด ๋œ๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์— ์ž‘์„ฑํ–ˆ๋‹ค.

fun hideOrShowNavigationBarOverAndroidR() {
    val windowInsetsController = WindowCompat.getInsetsController(
        requireActivity().window,
        requireActivity().window.decorView
    )
    
    requireActivity().window.decorView.setOnApplyWindowInsetsListener { view, windowInsets ->
        if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())) {
            windowInsetsController.hide(WindowInsetsCompat.Type.navigationBars())
        } else {
            windowInsetsController.show(WindowInsetsCompat.Type.navigationBars())
        }
        view.onApplyWindowInsets(windowInsets)
    }
}

 

์‹œ์Šคํ…œ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ. ์ „์ฒด ํ™”๋ฉด ๋ชจ๋“œ

์‹œ์Šคํ…œ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ. ์ „์ฒด ํ™”๋ฉด ๋ชจ๋“œ - Android R ๋ฏธ๋งŒ

 

decorView์˜ setSystemUiVisibility()์— ๋งค๊ฐœ๋ณ€์ˆ˜์— ํ”Œ๋ž˜๊ทธ๋“ค์„ ์„ค์ •ํ•œ๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

fun showOrHideSystemBar() {
    if (requireActivity().window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
        requireActivity().window.decorView.systemUiVisibility =
            (View.SYSTEM_UI_FLAG_IMMERSIVE
                // ์‹œ์Šคํ…œ๋ฐ”๊ฐ€ ์‚ฌ๋ผ์ง€๊ฑฐ๋‚˜ ๋ณด์ด๊ฑฐ๋‚˜ ํ•  ๋•Œ์— ์‹œ์Šคํ…œ๋ฐ” ์•„๋ž˜์˜ ์ฝ˜ํ…์ธ ๊ฐ€
                // ๋ฆฌ์‚ฌ์ด์ง•๋˜์ง€ ์•Š๋„๋ก ์„ค์ •ํ•œ๋‹ค.
                or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                // ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ”์™€ ์ƒํƒœ ๋ฐ”๋ฅผ ์ˆจ๊ธด๋‹ค.
                or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_FULLSCREEN)
    } else {
        // ์ฝ˜ํ…์ธ ์˜ y ์ขŒํ‘œ ๋ฐฉํ–ฅ ์œ„์ชฝ์ด ์•„๋‹ˆ๋ผ, z ์ขŒํ‘œ ๋ฐฉํ–ฅ ์œ„์ชฝ์œผ๋กœ
        // ์‹œ์Šคํ…œ๋ฐ”๊ฐ€ ๋‚˜ํƒ€๋‚˜๋Š” ๊ฒƒ์„ ํ…Œ์ŠคํŠธ๋กœ ํ™•์ธํ–ˆ๋‹ค.
        // ์‹œ์Šคํ…œ๋ฐ”๊ฐ€ ์ฝ˜ํ…์ธ ๋ฅผ ๊ฐ€๋ฆด ์ˆ˜ ์žˆ๋‹ค.
        requireActivity().window.decorView.systemUiVisibility = (
            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            )
    }
}

 

 

์‹œ์Šคํ…œ ๋ฐ” ์ˆจ๊ธฐ๊ธฐ. ์ „์ฒด ํ™”๋ฉด ๋ชจ๋“œ - Android R ์ด์ƒ

https://developer.android.com/develop/ui/views/layout/immersive#type

 

Hide system bars for immersive mode  |  Android Developers

Some content is best experienced in fullscreen without any indicators on the status bar or the navigation bar. Some examples are videos, games, image galleries, books, and presentation slides. This is referred to as immersive mode. This page shows how you

developer.android.com

WindowInsetsControllerCompat.hide()์— WindowInsetsCompat.Type.systemBars()๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋„ฃ์–ด์„œ ์“ฐ๋ฉด ๋œ๋‹ค.

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

fun hideOrShowSystemBarOverR() {
    val windowInsetsController = WindowCompat.getInsetsController (
    	requireActivity().window,
        requireActivity().window.decorView
    )
    
    requireActivity().window.decorView.setOnApplyWindowInsetsListener { view, windowInsets ->
    
        // ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ”๋‚˜ ์ƒํƒœ๋ฐ”๊ฐ€ ๋…ธ์ถœ๋˜์–ด ์žˆ์„ ๋•Œ
        if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())
            || windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())
        ) {
            // ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ”๋‚˜ ์ƒํƒœ๋ฐ” ๋ฟ๋งŒ์ด ์•„๋‹ˆ๋ผ ์‹œ์Šคํ…œ๋ฐ”๊นŒ์ง€๋„ ์ˆจ๊ธด๋‹ค.
            windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
        } else {
            windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
        }
    }
}

 

์‹œ์Šคํ…œ๋ฐ” ๋…ธ์ถœ ์—ฌ๋ถ€๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ๋ฆฌ์Šค๋„ˆ

์‹œ์Šคํ…œ๋ฐ” ๋…ธ์ถœ ์—ฌ๋ถ€๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ๋ฆฌ์Šค๋„ˆ - Android R ๋ฏธ๋งŒ

https://developer.android.com/training/system-ui/visibility?hl=ko 

 

UI ๊ฐ€์‹œ์„ฑ ๋ณ€๊ฒฝ์— ์‘๋‹ต  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

UI ๊ฐ€์‹œ์„ฑ ๋ณ€๊ฒฝ์— ์‘๋‹ต ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ์ด ๊ณผ์ •์—์„œ๋Š” ์•ฑ์ด ์‹œ์Šคํ…œ UI ๊ฐ€์‹œ์„ฑ ๋ณ€๊ฒฝ์— ๊ด€ํ•œ ์•Œ๋ฆผ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ๋ฆฌ์Šค๋„ˆ๋ฅผ ๋“ฑ

developer.android.com

 

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

requireActivity().window.decorView.setOnSystemUiVisibilityChangeListener { 
    if (it and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION == 0) {
    	// ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ” ๋…ธ์ถœ๋จ
    } else {
        // ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ” ์ˆจ๊ฒจ์ง
    }
    
    if (it and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
    	// ์ƒํƒœ๋ฐ” ๋…ธ์ถœ๋จ
    } else {
       // ์ƒํƒœ๋ฐ” ์ˆจ๊ฒจ์ง
    }
    
    if (it and View.SYSTEM_UI_FLAG_LOW_PROFILE == 0) {
       // ์‹œ์Šคํ…œ๋ฐ” ๋”ค ์ฒ˜๋ฆฌ ์—†์Œ
    } else {
       // ์‹œ์Šคํ…œ๋ฐ” ๋”ค ์ฒ˜๋ฆฌ๋จ
    }

}

 

 

์‹œ์Šคํ…œ๋ฐ” ๋…ธ์ถœ ์—ฌ๋ถ€๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ๋ฆฌ์Šค๋„ˆ - Android R ์ด์ƒ

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

val windowInsetsController = WindowCompat.getInsetsController(
    requireActivity().window,
    requireActivity().window.decorView
)

requireActivity().window.decorView.setOnApplyWindowInsetsListener { view, windowInsets ->
    if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())) {
        // ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ” ๋…ธ์ถœ๋จ
    } else {
        // ๋„ค๋น„๊ฒŒ์ด์…˜๋ฐ” ์ˆจ๊ฒจ์ง
    }
    
    if (windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) {
        // ์ƒํƒœ๋ฐ” ๋…ธ์ถœ๋จ
    } else {
        // ์ƒํƒœ๋ฐ” ์ˆจ๊ฒจ์ง
    }
    
    if (windowInsets.isVisible(WindowInsetsCompat.Type.captionBars())) {
        // ์ž๋ง‰ ๋…ธ์ถœ๋จ
    } else {
        // ์ž๋ง‰ ์ˆจ๊ฒจ์ง
    }
}

 

Android R ์ด์ƒ, ์‹œ์Šคํ…œ๋ฐ”๊ฐ€ ์ˆจ๊ฒจ์กŒ์„ ๋•Œ ์‚ฌ์šฉ์ž ์ธํ„ฐ๋ ‰์…˜์œผ๋กœ ์ž ๊น ์‹œ์Šคํ…œ๋ฐ” ๋…ธ์ถœ์‹œํ‚ค๊ธฐ

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” Fragment์—์„œ ์ž‘์„ฑํ–ˆ๋‹ค.

val windowInsetsController = WindowCompat.getInsetsController(
    requireActivity().window,
    requireActivity().window.decorView
)

// Android S(API Level 31)์—์„œ deprecated
windowInsetsController.systemBarsBehavior =
    WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH
   
// Android S(API Level 31)์—์„œ deprecated
windowInsetsController.systemBarsBehavior =
    WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE 

// ํ™”๋ฉด ์ƒ๋‹จ ๋ถ€๋ถ„์„ ์œ„์—์„œ ์•„๋ž˜๋กœ ์“ธ์–ด๋‚ด๋ฆฌ๋Š” ์ œ์Šค์ณ, 
// ํ˜น์€ ํ™”๋ฉด ํ•˜๋‹จ ๋ถ€๋ถ„์„ ์•„๋ž˜์—์„œ ์œ„๋กœ ์“ธ์–ด๋‚ด๋ฆฌ๋Š” ์ œ์Šค์ณ์—
// ์‹œ์Šคํ…œ๋ฐ”๊ฐ€ ํˆฌ๋ช…ํ•˜๊ฒŒ ๋…ธ์ถœ๋˜์–ด ์ฝ˜ํ…์ธ  ์œ„์— ์ž ๊น ๋ฎ์˜€๋‹ค๊ฐ€ ์‚ฌ๋ผ์ง„๋‹ค.
windowInsetsController.systemBarsBehavior =
    WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

 

Android R ๋ฏธ๋งŒ์€ GestureDetector๋กœ ๊ตฌํ˜„ํ•˜๋ผ๊ณ  ํ•œ๋‹ค. 

https://developer.android.com/training/system-ui/immersive?hl=ko 

 

์ „์ฒด ํ™”๋ฉด ๋ชจ๋“œ ์‚ฌ์šฉ ์„ค์ •  |  Android ๊ฐœ๋ฐœ์ž  |  Android Developers

์ „์ฒด ํ™”๋ฉด ๋ชจ๋“œ ์‚ฌ์šฉ ์„ค์ • ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ๋™์˜์ƒ, ๊ฒŒ์ž„, ์ด๋ฏธ์ง€ ๊ฐค๋Ÿฌ๋ฆฌ, ์ฑ…, ํ”„๋ ˆ์  ํ…Œ์ด์…˜ ์Šฌ๋ผ์ด๋“œ ๊ฐ™์€ ์ฝ˜ํ…์ธ ๋ฅผ ์ด์šฉํ•˜๊ธฐ

developer.android.com