Android的Fragment的自定義轉場動畫


Fragment間轉場可以使用setTransition()來設置系統默認的轉場動畫,也可以使用setCustomAnimations()方法來自定義轉場動畫。

getFragmentManager().beginTransaction() //An optional name for this back stack state, or null.addToBackStack()方法的參數如前面所說也可以為null
                .addToBackStack(null)//將替換的前一個事務添加的有Activity管理的返回棧中 //通過setCustomAnimation()方法來自定義Fragment間的過渡動畫,前兩個參數代表進入Fragment的動畫效果,后兩個參數代表退出Fragment的動畫效果
 .setCustomAnimations(R.anim.slide_in_right, R.anim.hold,R.anim.hold,R.anim.slide_out_right) .remove(this)//移除原來的Fragment
 .replace(R.id.content_2, fragment) .commit();

 

abstractFragmentTransaction setCustomAnimations(int enter, int exit, int popEnter, int popExit)

Set specific animation resources to run for the fragments that are entering and exiting in this transaction.

abstractFragmentTransaction setCustomAnimations(int enter, int exit)

Set specific animation resources to run for the fragments that are entering and exiting in this transaction.

參考 官方文檔  博客


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM