In my case, this came about due to the TabSelectedListener . In tab_layout.addOnTabSelectedListener() I have the onTabSelected method onTabSelected , where I opened another action without delay.
view.tab_layout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { override fun onTabReselected(tab: TabLayout.Tab?) { } override fun onTabUnselected(tab: TabLayout.Tab?) { } override fun onTabSelected(tab: TabLayout.Tab?) { if (tab?.position == 1) { MapsActivity.showScreen( this@ThisFragment ) } } })
I rewrote this method with a delay:
override fun onTabSelected(tab: TabLayout.Tab?) { if (tab?.position == 1) { // Show tab animation and open an activity. view.tab_layout.postDelayed({ // This check is optional. if (isAdded && view.tab_layout.selectedTabPosition == 1) { MapsActivity.showScreen( this@YourFragment ) } }, 250) } }
I also tried changing the duration value, but I donβt know how (it didnβt help):
view.tab_layout.animation = object: Animation() {} view.tab_layout.animation.duration = 1000 view.tab_layout.layoutAnimation = LayoutAnimationController(object: Animation() {}) view.tab_layout.layoutAnimation.delay = 1000f view.tab_layout.layoutAnimation.animation.duration = 1000
source share