透過集合功能整理內容
你可以依據偏好儲存及分類內容。
navigation3
Navigation 3 是專為搭配 Compose 設計的新導覽程式庫。
最近更新時間 |
穩定版 |
候選版 |
Beta 版 |
Alpha 版 |
2025 年 8 月 13 日 |
- |
- |
- |
1.0.0-alpha07 |
宣告依附元件
如要為 Navigation3 新增依附元件,必須將 Google Maven 存放區新增至專案。詳情請參閱 Google 的 Maven 存放區。
在應用程式或模組的 build.gradle
檔案中,新增所需構件的依附元件:
Groovy
dependencies {
implementation "androidx.navigation3:navigation3-runtime:1.0.0-alpha07"
implementation "androidx.navigation3:navigation3-ui:1.0.0-alpha07"
}
Kotlin
dependencies {
implementation("androidx.navigation3:navigation3-runtime:1.0.0-alpha07")
implementation("androidx.navigation3:navigation3-ui:1.0.0-alpha07")
}
如要進一步瞭解依附元件,請參閱「新增建構依附元件」一文。
意見回饋
您的意見可協助我們改善 Jetpack。如果您發現新問題,或是有改進這個程式庫的建議,請告訴我們。回報新問題前,請先查看這個程式庫的現有問題。只要按一下星號按鈕,即可投票給現有的問題。
建立新問題
詳情請參閱 Issue Tracker 文件。
這個構件沒有任何版本資訊。
1.0 版本
1.0.0-alpha07 版本
2025 年 8 月 13 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha07
。1.0.0-alpha07 版包含這些修訂項目。
MinSdk 更新
API 變更
SavedStateNavEntryDecorator
現在會使用 SaveableStateProvider
內建的 SaveableStateRegistry
儲存及還原狀態。(If8d9a)
- 現在,系統會將滑動邊緣做為參數提供給
predictivePopTransitionSpec
,讓您根據使用者啟動預測返回手勢的邊緣,自訂轉場效果。(I753a8)
修正錯誤
依附元件更新
1.0.0-alpha06 版本
2025 年 7 月 30 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha06
。1.0.0-alpha06 版包含這些修訂項目。
依附元件更新
1.0.0-alpha05 版本
2025 年 7 月 2 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha05
。1.0.0-alpha05 版包含這些修訂項目。
行為變更
NavEntry
的狀態現在會嚴格根據傳遞至 NavDisplay
的裝飾器清單而定。也就是說,如果有多個返回堆疊,裝飾器應沿著返回堆疊交換,才能保留返回堆疊中 NavEntry 的狀態。否則,系統會清除狀態,如同項目已彈出 (而非交換)。(I7a759、b/428033667)
1.0.0-alpha04 版本
2025 年 6 月 18 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha04
。1.0.0-alpha04 版包含這些修訂項目。
API 變更
依附元件變更
- Navigation3 現在依附於新的
androidx.navigationevent.compose
構件。
1.0.0-alpha03 版本
2025 年 6 月 4 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha03
。1.0.0-alpha03 版包含這些修訂項目。
修正錯誤
1.0.0-alpha02 版
2025 年 5 月 23 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha02
。1.0.0-alpha02 版包含這些修訂項目。
修正錯誤
1.0.0-alpha01 版
2025 年 5 月 20 日
發布 androidx.navigation3:navigation3-*:1.0.0-alpha01
。1.0.0-alpha01 版包含這些修訂項目。
新功能
Navigation3 是專為處理 Jetpack Compose 應用程式內導覽功能而建構的新導覽程式庫。androidx.navigation3.runtime
構件提供建構區塊,而 androidx.navigation3.ui
構件則透過 NavDisplay
API 提供 UI 層。開發人員可以直接將自己的狀態提供給 NavDisplay
可組合函式,根據開發人員狀態的變化來變更內容。
@Serialiable object Home : NavKey
@Serialiable object Chat : NavKey
val backStack = rememberNavBackStack(Home)
NavDisplay(backStack, entryProvider = entryProvider {
entry<Home> {
Column {
Text(“Home”)
Button(onClick = { backStack.add(Chat) } ) {
Text(“Go to Chat”)
}
}
}
entry<Chat> { /* My Composable Content */ }
})
詳情請參閱 Navigation3 指南。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-13 (世界標準時間)。
[[["容易理解","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-08-13 (世界標準時間)。"],[],[],null,["# navigation3\n===========\n\nAPI Reference \n[androidx.navigation3.runtime](/reference/kotlin/androidx/navigation3/runtime/package-summary) \n[androidx.navigation3.ui](/reference/kotlin/androidx/navigation3/ui/package-summary) \nNavigation 3 is a new navigation library designed to work with Compose. \n\n| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |\n|-----------------|----------------|-------------------|--------------|-----------------------------------------------------------------------|\n| August 13, 2025 | - | - | - | [1.0.0-alpha07](/jetpack/androidx/releases/navigation3#1.0.0-alpha07) |\n\nDeclaring dependencies\n----------------------\n\nTo add a dependency on navigation3, you must add the Google Maven repository to your\nproject. Read [Google's Maven repository](/studio/build/dependencies#google-maven)\nfor more information.\n\nAdd the dependencies for the artifacts you need in the `build.gradle` file for\nyour app or module: \n\n### Groovy\n\n```groovy\ndependencies {\n implementation \"androidx.navigation3:navigation3-runtime:1.0.0-alpha07\"\n implementation \"androidx.navigation3:navigation3-ui:1.0.0-alpha07\"\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n implementation(\"androidx.navigation3:navigation3-runtime:1.0.0-alpha07\")\n implementation(\"androidx.navigation3:navigation3-ui:1.0.0-alpha07\")\n}\n```\n\nFor more information about dependencies, see [Add build dependencies](/studio/build/dependencies).\n\nFeedback\n--------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues or have\nideas for improving this library. Please take a look at the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:1750212%20status:open)\nin this library before you create a new one. You can add your vote to an existing issue by\nclicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=1750212&template=2102223)\n\nSee the [Issue Tracker documentation](https://developers.google.com/issue-tracker)\nfor more information.\n\nThere are no release notes for this artifact.\n\nVersion 1.0\n-----------\n\n### Version 1.0.0-alpha07\n\nAugust 13, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha07` is released. Version 1.0.0-alpha07 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/b4562c71af5649ad7262ba4c7925899e6e93bdff..c359e97fece91f3767a7d017e9def23c7caf1f53/navigation3).\n\n**MinSdk Update**\n\n- The default minSdk for the AndroidX has been moved from API 21 to API 23 ([Ibdfca](https://android-review.googlesource.com/#/q/Ibdfca5942dbb414ca07594ba240093db14aad4df), [b/380448311](https://issuetracker.google.com/issues/380448311), [b/435705964](https://issuetracker.google.com/issues/435705964), [b/435705223](https://issuetracker.google.com/issues/435705223))\n\n**API Changes**\n\n- `SavedStateNavEntryDecorator` now uses the `SaveableStateRegistry` built into `SaveableStateProvider` to save and restore states. ([If8d9a](https://android-review.googlesource.com/#/q/If8d9aebde301f51faa78d4b1f471cf9f7d87f9cb))\n- The `predictivePopTransitionSpec` is now provided the swipe edge as a parameter, allowing you to customize the transition based on what edge the user started the Predictive Back gesture from. ([I753a8](https://android-review.googlesource.com/#/q/I753a8ba909347f89506006f66aca23298b2e3237))\n\n**Bug Fixes**\n\n- Fixed an issue that would cause custom scenes to be infinitely recalculated because the most recent scene was not being remembered. ([I7ba84](https://android-review.googlesource.com/#/q/I7ba84a56fe1cfd4f006c9b6c4c3e91b44a2bb2a5), [b/418153031](https://issuetracker.google.com/issues/418153031))\n\n**Dependency update**\n\n- Navigation3 now depends on [Navigation Event `1.0.0-alpha06`](/jetpack/androidx/releases/jetpack/androidx/releases/navigationevent#1.0.0-alpha06).\n\n### Version 1.0.0-alpha06\n\nJuly 30, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha06` is released. Version 1.0.0-alpha06 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/c920d69612c07600c8d244ef8fe3df5ec775da88..b4562c71af5649ad7262ba4c7925899e6e93bdff/navigation3).\n\n**Dependency Update**\n\n- Navigation3 now depends on [Navigation Event `1.0.0-alpha05`](/jetpack/androidx/releases/navigationevent#1.0.0-alpha05).\n\n### Version 1.0.0-alpha05\n\nJuly 2, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha05` is released. Version 1.0.0-alpha05 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/3a0aa7a0552da83ba3994838f5db40d0d7a6196f..c920d69612c07600c8d244ef8fe3df5ec775da88/navigation3).\n\n**Behavior Changes**\n\n- The `NavEntry`'s state is now strictly based on the current list of decorators passed to the `NavDisplay`. This means that decorators should be swapped along your back stacks in the case of multiple back stacks in order to preserve the state of the NavEntries on the back stack. Otherwise, the states will be cleared as if the entries were popped (instead of a swap). ([I7a759](https://android-review.googlesource.com/#/q/I7a759e37580404cf9c3a35b1c2a8f18b3d20646e), [b/428033667](https://issuetracker.google.com/issues/428033667))\n\n### Version 1.0.0-alpha04\n\nJune 18, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha04` is released. Version 1.0.0-alpha04 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/4fb12d1b1dc4dcae8ca603c7a5db938cc1abe39c..b454ea392cd18cccb078ef60a3221719164f7bbc/navigation3).\n\n**API Changes**\n\n- `NavEntry.content` is now private. To invoke `NavEntry` content, call the new `NavEntry.Content()` api which no longer requires a `key` parameter to invoke. ([Icd0fd](https://android-review.googlesource.com/#/q/Icd0fd2244c3d29557b0803ef2abb199c18cbdbdc), [b/420991203](https://issuetracker.google.com/issues/420991203))\n- `NavEntry.key` is now a private field. The `NavEntry` and its relevant states should be identified by the new `contentKey` field which is generated from the new `contentKeyFactory` lambda and defaults to a saveable hash generated from `NavEntry.key` ([I81a6c](https://android-review.googlesource.com/#/q/I81a6ced3a7bebf561c7206fcdf9402bc80c12752), [b/422001357](https://issuetracker.google.com/issues/422001357), [b/420991203](https://issuetracker.google.com/issues/420991203) [I2d7d4](https://android-review.googlesource.com/#/q/I2d7d4daba257e19bc9abe5ea64540126af18adf0), [b/420991203](https://issuetracker.google.com/issues/420991203), [b/422841812](https://issuetracker.google.com/issues/422841812))\n\n**Dependency Changes**\n\n- Navigation3 now depends on the new `androidx.navigationevent.compose` artifact.\n\n### Version 1.0.0-alpha03\n\nJune 4, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha03` is released. Version 1.0.0-alpha03 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/3db836162afb266b54eb37d28c7c12231755fc9b..4fb12d1b1dc4dcae8ca603c7a5db938cc1abe39c/navigation3).\n\n**Bug Fixes**\n\n- `Navigation3` will no longer clear decorator states for `backStacks` that have been swapped out and replaced with another `backStack` instance. ([I28a42](https://android-review.googlesource.com/#/q/I28a42b98cc811be99d8380b1cfceee02b42608ab), [b/415076044](https://issuetracker.google.com/issues/415076044))\n\n### Version 1.0.0-alpha02\n\nMay 23, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha02` is released. Version 1.0.0-alpha02 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/1c211305886d70caa42620facce1b97ed7e47bf5..3db836162afb266b54eb37d28c7c12231755fc9b/navigation3).\n\n**Bug Fixes**\n\n- Fixed an issue with the `SavedStateNavEntryDecorator` which caused collisions for different data classes with the same property values. ([b/418070648](https://issuetracker.google.com/418070648), [Iff4775](https://android-review.googlesource.com/#/q/Iff47751d5de26bfee744069461cee38419988699))\n- Fixed a missing class issue that would cause crashes when running without declaring explicit dependencies. ([b/419049149](https://issuetracker.google.com/419049149), [I4b4ed](https://android-review.googlesource.com/#/q/I4b4edbf046a62164e56e1871ca9918d9683a2abf))\n\n### Version 1.0.0-alpha01\n\nMay 20, 2025\n\n`androidx.navigation3:navigation3-*:1.0.0-alpha01` is released. Version 1.0.0-alpha01 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/1c211305886d70caa42620facce1b97ed7e47bf5/navigation3).\n\n**New Features**\n\n[Navigation3](https://developer.android.com/guide/navigation/navigation-3) is a new navigation library built specifically to handle Jetpack Compose in-app navigation. The `androidx.navigation3.runtime` artifact provides the building blocks, while the `androidx.navigation3.ui` artifact provides the UI layer via the `NavDisplay` API. Developers can provide their own state directly to the `NavDisplay` composable function, which changes the content based on changes in the developer state. \n\n @Serialiable object Home : NavKey\n @Serialiable object Chat : NavKey\n\n val backStack = rememberNavBackStack(Home)\n\n NavDisplay(backStack, entryProvider = entryProvider {\n entry\u003cHome\u003e {\n Column {\n Text(\"Home\")\n Button(onClick = { backStack.add(Chat) } ) {\n Text(\"Go to Chat\")\n } \n }\n }\n entry\u003cChat\u003e { /* My Composable Content */ }\n })\n\nFor more information, see the [Navigation3 guide](http://goo.gle/nav3)."]]