Skip to content

Instantly share code, notes, and snippets.

@EminYahyayev
Last active August 29, 2015 14:20
Show Gist options
  • Save EminYahyayev/21a4ba62cbdb0a0597ac to your computer and use it in GitHub Desktop.
Save EminYahyayev/21a4ba62cbdb0a0597ac to your computer and use it in GitHub Desktop.
@Override
public void onMenuToggle(final boolean isOpen) {
setBackgroundDimming(isOpen);
}
private void setBackgroundDimming(boolean dimmed) {
final float targetAlpha = dimmed ? 1f : 0;
final int endVisibility = dimmed ? View.VISIBLE : View.GONE;
mDimmerView.setVisibility(View.VISIBLE);
mDimmerView.animate()
.alpha(targetAlpha)
.setDuration(DIM_ANIMATION_DURATION)
.withEndAction(new Runnable() {
@Override
public void run() {
mDimmerView.setVisibility(endVisibility);
}
})
.start();
}
@OnClick(R.id.dimmer_view)
protected void dimmedBackgroundClicked(View sender) {
mFloatingActionMenu.close(true);
}
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/header_shadow">
<View
android:id="@+id/dimmer_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80ffffff"
android:alpha="0"
android:visibility="gone"/>
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/fab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|right"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
fab:menu_fab_size="normal">
<com.github.clans.fab.FloatingActionButton
style="@style/Rombe.Widget.FloatingActionButton"/>
<com.github.clans.fab.FloatingActionButton
style="@style/Rombe.Widget.FloatingActionButton"/>
</com.github.clans.fab.FloatingActionMenu>
</FrameLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment