用戶navigate forward的時(shí)候要保存back stack,讓backstack去響應(yīng)back button的點(diǎn)擊
當(dāng)要為fragment創(chuàng)建一個(gè)backstack棧時(shí)结缚,需要執(zhí)行多個(gè)transaction凉倚,這時(shí)需要執(zhí)行setreorderingallowed(true)秆剪,來(lái)優(yōu)化transaction的執(zhí)行(有些操作會(huì)被合并)衩侥。
Fragment transition
Basic transition:fade茫藏,open民鼓,close
custom animation
fragment中view的切換動(dòng)畫薇芝,在fragment上設(shè)置,setEnterTransition
對(duì)于非sharedElement生效摹察。setSharedElementEnterTransition
對(duì)于shared element生效恩掷。在transaction中指定sharedelement。
當(dāng)從detail view中返回recycler view中時(shí)供嚎,因?yàn)閟hared element還沒有在RecyclerView還沒有l(wèi)ayout黄娘,所以要onCreateview
中調(diào)用postponeEnterTransition,然后監(jiān)聽layout完成后調(diào)用startPostponedEnterTransition克滴,同時(shí)transaction還需要設(shè)置setreorderingallowed(true)逼争,因?yàn)閑nter和exit的fragment會(huì)同時(shí)存在。
不要在retain instance fragment中保存
- views
- contexts(activities)
- callback reference