I built a project based on Scrolling Activity
, and faced a strange issue. Consider the following scenario:
I click on fab button to go
I had the same problem. I called the .hide()
method on the FragmentTransaction
and it worked for me.
fab.setOnClickListener {
val fragmentManager = fragmentManager
val fragmentTransaction = fragmentManager?.beginTransaction()
val fragment = YourFragment()
fragmentTransaction?.add(R.id.fragment_container, fragment)
fragmentTransaction?.addToBackStack(null)
fragmentTransaction?.hide(this)
fragmentTransaction?.commit()
}