Android Jetpack Navigation with ViewPager and TabLayout

前端 未结 5 816
面向向阳花
面向向阳花 2020-12-13 10:09

For a new app i use Jetpack Navigation Library to implement proper back navigation. The first level of navigation is a navigation drawer which works fine with jetpack naviga

5条回答
  •  忘掉有多难
    2020-12-13 10:16

    What worked for me so far:

    In navigation_graph.xml

    • make your ViewPagerFragment the root of a nested graph
    • connect your in and out navigation to the nested graph

    in nested graph:

    • add the ChildFragments of the ViewPager to the nested graph

    I didnt need to change the ViewPager, and Directions were created for the Child Fragments so navigation is possible from there.

提交回复
热议问题