Created
March 16, 2016 11:46
-
-
Save twiceyuan/3ce699650620f4c316d9 to your computer and use it in GitHub Desktop.
监听 RecyclerView 滚动到顶部 / 底部
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
import android.support.v7.widget.RecyclerView; | |
public abstract class OnVerticalScrollListener extends RecyclerView.OnScrollListener { | |
@Override | |
public final void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
if (!recyclerView.canScrollVertically(1)) { | |
onScrolledToEnd(); | |
} else if (!recyclerView.canScrollVertically(-1)) { | |
onScrolledToTop(); | |
} else if (dy < 0) { | |
onScrolledUp(); | |
} else if (dy > 0) { | |
onScrolledDown(); | |
} | |
} | |
public void onScrolledUp() { | |
} | |
public void onScrolledDown() { | |
} | |
public void onScrolledToEnd() { | |
} | |
public void onScrolledToTop() { | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment