Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FloatingActionButton dimming
@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>
@Alxzu

This comment has been minimized.

Copy link

Alxzu commented Dec 9, 2015

Thanks! very useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.