Ashok-Varma / BottomNavigation

This Library helps users to use Bottom Navigation Bar (A new pattern from google) with ease and allows ton of customizations
Apache License 2.0
4.36k stars 689 forks source link

FloatingActionButton can't show/hide after call setFab() #54

Open jordenchang55 opened 8 years ago

jordenchang55 commented 8 years ago

I have 4 fragments and use BottomNavigation to switch between them. In some fragments, I don't want to use fab, so I try to call mFAB.hide() to hide it. No matter I call this method in activity or fragment, it just doesn't work, the button still there.

But if I remove the line, mBottomNavigationBar.setFab(mFAB), the button will show/hide as expected when switching between tabs.

Ashok-Varma commented 8 years ago

The Bug is due to animations. mFab.hide() uses animation to hide the fab. But at the same time since bottomBar state changed it is trying to animate fab cancelling previous animation so hide animation is stopped. i will try to fix it in upcoming release. for now instead of

mFAB.hide()

try to call

mFAB.setVisibility
SailFlorve commented 7 years ago

Yeah I have the same case and met this bug, longing for fixing it!

ahmadmust8 commented 6 years ago

it work if you write it like this


override fun onTabSelected(position: Int) {

       if (position == 2){
            fab.visibility = View.GONE
        }else{
            fab.visibility = View.VISIBLE
        }
    }