사용자는 앱의 기본 화면으로 쉽게 돌아갈 수 있는 방법이 필요합니다. 이렇게 하려면 기본 활동을 제외한 모든 활동의 앱 바에 위로 버튼 을 제공합니다. 사용자가 위 버튼을 선택하면 앱이 상위 활동으로 이동합니다.
이 페이지에서는 Jetpack Navigation 구성요소를 사용하여 앱 바에 위로 버튼을 추가하는 방법을 보여줍니다.
자세한 내용은 NavigationUI로 UI 구성요소 업데이트를 참고하세요.
앱 바 구성
AppBarConfiguration를 사용하여 앱 바를 구성합니다.
AppBarConfiguration에서 앱 바에 최상위 대상을 알릴 수 있습니다. 탐색 창이 구성된 경우 창 메뉴 아이콘 이 최상위 대상의 앱 바에 표시됩니다. 탐색 창이 구성되지 않으면 최상위 수준 대상에서 탐색 버튼이 숨겨집니다.
두 경우 모두 다른 모든 대상에 '위로' 버튼이 표시됩니다. 위 버튼을 누르면 navigateUp()이 호출됩니다.
다음 예는 AppBarConfiguration를 사용하여 앱 바를 구성하는 방법을 보여줍니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 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,["# Add an Up action\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to add components in Compose. \n[Navigate from top app bar →](/develop/ui/compose/components/app-bars-navigate) \n\nUsers need an easy way to get back to your app's main screen. To do this, provide an *Up*\nbutton on the app bar\nfor all activities except the main one. When the user selects the Up button, the app navigates to\nthe parent activity.\n\nThis page shows you how to add an Up button to an app bar using the Jetpack Navigation component.\nFor a more detailed explanation, see\n[Update UI components with NavigationUI](/guide/navigation/navigation-ui).\n| **Note:** We recommend using the Jetpack Navigation component to handle your app navigation. This component handles navigating up from the current screen in your app when the user taps the Up button. To learn more, see the documentation for the [Jetpack Navigation component](/guide/navigation).\n\nConfigure your app bar\n----------------------\n\nConfigure your app bar using an\n[AppBarConfiguration](/reference/androidx/navigation/ui/AppBarConfiguration).\nFrom the `AppBarConfiguration`, you can inform the app bar of your top-level\ndestinations. If the navigation drawer is configured, the drawer menu icon\ndisplays on the app\nbar on top-level destinations. If the navigation drawer isn't configured, the navigation button is\nhidden on top-level destinations.\n\nIn both cases, the Up button displays on all other destinations. Pressing the Up button calls\n[navigateUp()](/reference/androidx/navigation/NavController#navigateUp()).\n\nThe following example shows how to configure an app bar using\n`AppBarConfiguration`: \n\n### Kotlin\n\n```kotlin\n override fun onCreate(savedInstanceState: Bundle?) {\n ...\n val navController = findNavController(R.id.nav_host_fragment_activity_main)\n \n val appBarConfiguration = AppBarConfiguration(\n setOf(\n R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications\n )\n )\n binding.myToolbar.setupWithNavController(navController, appBarConfiguration)\n }\n \n```\n\n### Java\n\n```java\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n ...\n NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);\n\n AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(\n R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)\n .build();\n NavigationUI.setupWithNavController(binding.myToolbar, navController, appBarConfiguration);\n }\n \n```"]]