I am trying to hide my FloatingActionButton fabLocation programmatically with :
fabLocation.setVisibility(View.GONE)
but it do
FloatingActionButtons anchored to AppBarLayouts have a special relationship where their visibility is controlled by the scroll position of the AppBarLayout.
You can turn this off via the behavior_autoHide attribute:
You can also do this programmatically if you wish:
EDIT:
fab.getBehavior() was not correct, use getBehavior() from its LayoutParams
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
FloatingActionButton.Behavior behavior = (FloatingActionButton.Behavior) lp.getBehavior();
if (behavior != null) {
behavior.setAutoHideEnabled(false);
} else {
behavior = new FloatingActionButton.Behavior();
behavior.setAutoHideEnabled(false);
lp.setBehavior(behavior);
}