Skip to content

Instantly share code, notes, and snippets.

View ehehhh's full-sized avatar

Rait Maltsaar ehehhh

  • Tallinn, Estonia
View GitHub Profile
@ehehhh
ehehhh / ScrollAwareFabBehavior.java
Created October 3, 2017 15:24
A FloatingActionButton behavior, which hides the FAB when the user scrolls down and shows it when the user scrolls up.
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
public class ScrollAwareFabBehavior extends FloatingActionButton.Behavior {
@ehehhh
ehehhh / ScrollToTopBehavior.java
Last active March 23, 2017 14:32
A CoordinatorLayout behavior written to hide a FAB, when RecyclerView is scrolled to top and show it, when first item is scrolled out of view.
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
public class ScrollToTopBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {