Fragment transaction animation: slide in and slide out

前端 未结 6 1452
梦谈多话
梦谈多话 2020-11-27 09:44

I\'ve check some tutorials for animate transaction between fragments. I\'ve used this method for animation and it works:

fragmentTransaction.setCustomAnimatio         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 10:21

    Have the same problem with white screen during transition from one fragment to another. Have navigation and animations set in action in navigation.xml.

    Background in all fragments the same but white blank screen. So i set navOptions in fragment during executing transition

              //Transition options
            val options = navOptions {
                anim {
                    enter = R.anim.slide_in_right
                    exit = R.anim.slide_out_left
                    popEnter = R.anim.slide_in_left
                    popExit = R.anim.slide_out_right
                }
            }
    
    .......................
    
      this.findNavController().navigate(SampleFragmentDirections.actionSampleFragmentToChartFragment(it),
                        options)
    

    It worked for me. No white screen between transistion. Magic )

提交回复
热议问题