- // Select the new tab if it is the first one. For some odd reason, Android doesn't select the first tab if it is the only one, which causes problems with the new tab position logic above.
- if (newTabPosition == 0)
- tabLayout.selectTab(newTab)
+ // Scroll to the new tab position if moving to the new tab.
+ if (moveToTab)
+ tabLayout.post {
+ tabLayout.setScrollPosition(newTabPosition, 0F, false, false)
+ }
+
+ // Show the app bar if it is at the bottom of the screen and the new tab is taking focus.
+ if (bottomAppBar && moveToTab && appBarLayout.translationY != 0f) {
+ // Animate the bottom app bar onto the screen.
+ objectAnimator = ObjectAnimator.ofFloat(appBarLayout, "translationY", 0f)