Navigation Component Formatting Standards
Fragments
- Fragments ids should start with feature name and end with
_dest - Best practice is to use a string resource for
labelattribute
<fragment
android:id="@+id/topic_dest"
android:name="io.vokal.topic.TopicFragment"
android:label="@string/topic"
tools:layout="@layout/fragment_topic"/>Navigation Graph
- Try to compound destinations in nested graphs. A nested graph should be about destinations which fall under the same category and can navigated through.
- Each navigation should start with the category and be suffixed with
_navigation.xml- for example main navigation is
main_navigation.xml
- for example main navigation is
- each navigation graph id must be prefixed with
categoryand end with_graph
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/feed_graph"
app:startDestination="@+id/pager_dest">
...
</navigation>Actions
Actions are used to navigate from one destination into another. Global actions
are handy to be reused by any destination going into a specific destination
- If going from
a_desttob_destthen the action id isa_dest_to_b_dest - For global destinations use the following format
global_c_destwherec_destis landed from different destinations.