Issue
My FragmentManager code look likes so, what should I do so that the behaviour in question can be achieved?
supportFragmentManager.beginTransaction().hide(HomeFragment.newInstance())
.apply {
replace(
R.id.fragment_container_view,
HomeFragment.newInstance()
)
setCustomAnimations(
android.R.anim.slide_out_right,
android.R.anim.fade_out,
android.R.anim.slide_in_left,
android.R.anim.fade_out
)
addToBackStack(FragmentType.HOME_FRAGMENT)
commit()
}
Solution
add() method keeps on adding fragments on top of the previous fragment in FragmentContainer.
While replace() methods clears all the previous Fragment from Containers and then add it in FragmentContainer.
supportFragmentManager.beginTransaction().hide(HomeFragment.newInstance())
.apply {
add(
R.id.fragment_container_view,
HomeFragment.newInstance()
)
setCustomAnimations(
android.R.anim.slide_out_right,
android.R.anim.fade_out,
android.R.anim.slide_in_left,
android.R.anim.fade_out
)
addToBackStack(FragmentType.HOME_FRAGMENT)
commit()
}
Answered By - Hossein

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.