![](/img/trans.png)
[英]BottomNavigationView + Save fragment states while navigating to different tabs
[英]How to achieve different animation while navigating to the same fragment with BottomNavigationView and navigation component?
我有以下屏幕:
Bottom Navigation stack: [A] [B]
Root fragments: [HomeFragment], [SettingsFragment]
Nested fragments: [ProfileFragment]
我想在導航到 ProfileFragment 時實現不同的 animation:
我在支持多個后台堆棧的 bottomNavigationView 旁邊使用導航組件。 從 SettingsFragment 導航到 ProfileFragment 時,我在導航圖中使用了以下過渡動畫:
app:enterAnim="@anim/slide_right"
app:exitAnim="@anim/slide_left"
一切正常,但我不想在用戶轉到 HomeFragment 然后通過 bottomNavigationView 返回 ProfileFragment 時使用 slide_right animation。
我像這樣設置 navController:
bottomNavigationView.setupWithNavController(navController)
有什么方法可以在通過 bottomNavigationView 導航到 ProfileFragment 時使用不同的 animation(例如淡入、淡出),但在從 SettingsFragment 導航時使用我的自定義 slide_right animation?
經過大量試驗和錯誤,將導航組件版本從 2.5.3 降級到 2.5.0 對我有用。 沒有任何進一步的改變,它開始按預期工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.