Skip to content

Instantly share code, notes, and snippets.

@ewintory ewintory/activity forked from avrahamshukron/activity
Last active Aug 29, 2015

Embed
What would you like to do?
@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
You can’t perform that action at this time.