Created
March 7, 2016 02:11
-
-
Save jaredsburrows/e673a28e7713040393c5 to your computer and use it in GitHub Desktop.
Hide/Show Fab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final OnVisibilityChangedListener searchVisibilityChangedListener = new OnVisibilityChangedListener() { | |
@Override | |
public void onShown(final FloatingActionButton fab) { | |
super.onShown(fab); | |
} | |
@Override | |
public void onHidden(final FloatingActionButton fab) { | |
super.onHidden(fab); | |
floatingActionButton.setImageResource(R.drawable.ic_search_white_24dp); | |
floatingActionButton.show(); | |
} | |
}; | |
final OnVisibilityChangedListener editVisibilityChangedListener = new OnVisibilityChangedListener() { | |
@Override | |
public void onShown(final FloatingActionButton fab) { | |
super.onShown(fab); | |
} | |
@Override | |
public void onHidden(final FloatingActionButton fab) { | |
super.onHidden(fab); | |
floatingActionButton.setImageResource(R.drawable.ic_edit_white_24dp); | |
floatingActionButton.show(); | |
} | |
}; | |
@Override | |
public void onPageSelected(final int position) { | |
if (position == FRAGMENT_POSITION_ONE) { | |
this.floatingActionButton.hide(searchVisibilityChangedListener); | |
} else if (position == FRAGMENT_POSITION_TWO) { | |
this.floatingActionButton.hide(editVisibilityChangedListener); | |
} else { | |
this.floatingActionButton.hide(addVisibilityChangedListener); | |
} | |
this.currentPage = position; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment