קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Navigation 3 היא ספריית ניווט חדשה שמיועדת לעבודה עם Compose. עם Navigation 3 יש לכם שליטה מלאה על סטאק החזרה, והניווט אל יעדים ומהם פשוט כמו הוספה והסרה של פריטים מרשימת. הוא יוצר מערכת ניווט גמישה באפליקציות באמצעות:
מוסכמות ליצירת מודל של סטאק אחורה, שבו כל רשומה בסטאק האחורי מייצגת תוכן שהמשתמש עבר אליו
ממשק משתמש שמתעדכן באופן אוטומטי עם שינויים ב-back stack (כולל אנימציות)
היקף לפריטים ב-back stack, שמאפשר לשמור את המצב בזמן שהפריט נמצא ב-back stack
מערכת של פריסות דינמיות שמאפשרת להציג כמה יעדים בו-זמנית, ומאפשרת מעבר חלק בין הפריסות האלה
מנגנון שמאפשר לתוכן לתקשר עם הפריסה הראשית שלו (מטא-נתונים)
באופן כללי, מטמיעים את Navigation 3 בדרכים הבאות:
מגדירים את התוכן שאליו המשתמשים יכולים לנווט באפליקציה, לכל תוכן מוקצה מפתח ייחודי, ומוסיפים פונקציה כדי לקשר את המפתח הזה לתוכן. פתרון מפתחות לתוכן
יוצרים סטאק אחורה שאליו מועברים מפתחות והם מוסרים כשמשתמשים מנווטים באפליקציה. אפשר לעיין במאמר יצירת סטאק אחורה.
משתמשים ב-NavDisplay כדי להציג את סטאק החזרה של האפליקציה. בכל פעם שסטאק הקוד בחלק העורפי משתנה, ממשק המשתמש מתעדכן כדי להציג תוכן רלוונטי. הצגת מקבץ הפריטים הקודם
משנים את אסטרטגיות הסצנות של NavDisplay לפי הצורך כדי לתמוך בפריסות מותאמות ופלטפורמות שונות.
ניווט 3 משפר את Jetpack Navigation API המקורי בדרכים הבאות:
שילוב פשוט יותר עם Compose
שליטה מלאה על סטאק הקוד הקודם
מאפשרת ליצור פריסות שיכולות לקרוא יותר מיעד אחד מהמקבץ הקודם באותו זמן, וכך להתאים את עצמן לשינויים בגודל החלון ובנתונים נכנסים אחרים.
בפוסט הזה בבלוג מוסבר בהרחבה על העקרונות של Navigation 3 ועל האפשרויות של עיצוב ממשקי API.
דוגמאות קוד
מאגר המתכונים מכיל דוגמאות לשימוש באבני הבניין של Navigation 3 כדי לפתור אתגרי ניווט נפוצים.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# Navigation 3\n\n| **Experimental:** Navigation 3 is in alpha. The APIs may change in the future. Please file bugs and feedback using the [issue tracker](https://issuetracker.google.com/issues/new?component=1750212&template=2102223).\n\nNavigation 3 is a new navigation library designed to work with Compose. With\nNavigation 3, you have full control over your back stack, and navigating to and\nfrom destinations is as simple as adding and removing items from a list. It\ncreates a flexible app navigation system by providing:\n\n- Conventions for modeling a back stack, where each entry on the back stack represents content that the user has navigated to\n- A UI that automatically updates with back stack changes (including animations)\n- A scope for items in the back stack, allowing state to be retained while an item is in the back stack\n- An adaptive layout system that allows multiple destinations to be displayed at the same time, and allowing seamless switching between those layouts\n- A mechanism for content to communicate with its parent layout (metadata)\n\nAt a high level, you implement Navigation 3 in the following ways:\n\n1. Define the content that users can navigate to in your app, each with a unique key, and add a function to resolve that key to the content. See [Resolve keys\n to content](/guide/navigation/navigation-3/basics#resolve-keys).\n2. Create a back stack that keys are pushed onto and removed as users navigate your app. See [Create a back stack](/guide/navigation/navigation-3/basics#create-back).\n3. Use a [`NavDisplay`](/reference/kotlin/androidx/navigation3/ui/package-summary#NavDisplay(kotlin.collections.List,androidx.compose.ui.Modifier,androidx.compose.ui.Alignment,kotlin.Function1,kotlin.collections.List,androidx.navigation3.ui.SceneStrategy,androidx.compose.animation.SizeTransform,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function1)) to display your app's back stack. Whenever the back stack changes, it updates the UI to display relevant content. See [Display\n the back stack](/guide/navigation/navigation-3/basics#display-back).\n4. Modify `NavDisplay`'s [scene strategies](/guide/navigation/navigation-3/custom-layouts) as needed to support adaptive layouts and different platforms.\n\nYou can see the [full source code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigation3/) for Navigation 3 on AOSP.\n\nImprovements upon Jetpack Navigation\n------------------------------------\n\nNavigation 3 improves upon the original Jetpack Navigation API in the following\nways:\n\n- Provides a simpler integration with Compose\n- Offers you full control of the back stack\n- Makes it possible to create layouts that can read more than one destination from the back stack at the same time, allowing them to adapt to changes in window size and other inputs.\n\nRead more about Navigation 3's principles and API design choices in [this blog\npost](https://android-developers.googleblog.com/2025/05/announcing-jetpack-navigation-3-for-compose.html).\n\nCode samples\n------------\n\nThe [recipes repository](https://github.com/android/nav3-recipes) contains examples of how to use the\nNavigation 3 building blocks to solve common navigation challenges."]]