使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
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")
}
如需详细了解依赖项,请参阅添加 build 依赖项。
反馈
您的反馈将帮助我们改进 Jetpack。如果您发现了新问题,或对此库有任何改进建议,请告诉我们。创建新问题前,请先查看此库中的现有问题。您可以点击星标按钮,为现有问题投票。
创建新问题
如需了解详情,请参阅问题跟踪器文档。
此工件没有版本说明。
版本 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)
bug 修复
依赖项更新
版本 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 中包含这些提交内容。
bug 修复
版本 1.0.0-alpha02
2025 年 5 月 23 日
发布了 androidx.navigation3:navigation3-*:1.0.0-alpha02
。版本 1.0.0-alpha02 中包含这些提交内容。
bug 修复
版本 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 提供界面层。开发者可以直接向 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 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-13。
[null,null,["最后更新时间 (UTC):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)."]]