UI 공개 상태 변경에 응답
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 과정에서는 앱이 알림을 받을 수 있도록 리스너를 등록하는 방법을 설명합니다.
시스템 UI 가시성 변경사항에 대해 알아봤습니다 이 기능은
시스템 표시줄의 숨기기/표시와 UI의 다른 부분을 동기화합니다.
리스너 등록
시스템 UI 가시성 변경에 대한 알림을 받으려면
뷰에 View.OnSystemUiVisibilityChangeListener
추가
이때 뷰는 일반적으로 탐색 가시성을 제어하는 데 사용하는 뷰입니다.
예를 들어, 액티비티의
onCreate()
메서드:
Kotlin
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.
} else {
// TODO: The system bars are NOT visible. Make any desired
// adjustments to your UI, such as hiding the action bar or
// other navigational controls.
}
}
자바
View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener
(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.
} else {
// TODO: The system bars are NOT visible. Make any desired
// adjustments to your UI, such as hiding the action bar or
// other navigational controls.
}
}
});
일반적으로 시스템 표시줄의 변경사항과 UI의 동기화를 유지하는 것이 좋습니다.
가시성을 제공합니다 예를 들어, 이 리스너를 사용하여
상태 표시줄이 숨겨지고 표시됩니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Respond to UI visibility changes\n\nThis lesson describes how to register a listener so that your app can get notified\nof system UI visibility changes. This is useful if you want to\nsynchronize other parts of your UI with the hiding/showing of system bars.\n\nRegister a Listener\n-------------------\n\nTo get notified of system UI visibility changes, register an\n[View.OnSystemUiVisibilityChangeListener](/reference/android/view/View.OnSystemUiVisibilityChangeListener) to your view.\nThis is typically the view you are using to control the navigation visibility.\n\nFor example, you could add this code to your activity's\n[onCreate()](/reference/android/app/Activity#onCreate(android.os.Bundle)) method: \n\n### Kotlin\n\n```kotlin\nwindow.decorView.setOnSystemUiVisibilityChangeListener { visibility -\u003e\n // Note that system bars will only be \"visible\" if none of the\n // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.\n if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {\n // TODO: The system bars are visible. Make any desired\n // adjustments to your UI, such as showing the action bar or\n // other navigational controls.\n } else {\n // TODO: The system bars are NOT visible. Make any desired\n // adjustments to your UI, such as hiding the action bar or\n // other navigational controls.\n }\n}\n```\n\n### Java\n\n```java\nView decorView = getWindow().getDecorView();\ndecorView.setOnSystemUiVisibilityChangeListener\n (new View.OnSystemUiVisibilityChangeListener() {\n @Override\n public void onSystemUiVisibilityChange(int visibility) {\n // Note that system bars will only be \"visible\" if none of the\n // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.\n if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {\n // TODO: The system bars are visible. Make any desired\n // adjustments to your UI, such as showing the action bar or\n // other navigational controls.\n } else {\n // TODO: The system bars are NOT visible. Make any desired\n // adjustments to your UI, such as hiding the action bar or\n // other navigational controls.\n }\n }\n});\n```\n\nIt's generally good practice to keep your UI in sync with changes in system bar\nvisibility. For example, you could use this listener to hide and show the action bar in\nconcert with the status bar hiding and showing."]]