Google have released Design library, I am using
compile 'com.android.support:design:22.2.1'
However I cant see any code examples of how to use this library and how to animate the FAB
bar on scroll. I guess I can listen for scroll events on the ListView
and then animate the button myself, but is this not baked into the API (is this not the point of this support library).
Is there examples for this ?
If you're using RecyclerView
and you're looking for something simple, you can try this:
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy){
if (dy > 0)
fabAddNew.hide();
else if (dy < 0)
fabAddNew.show();
}
});
By replacing 0
with a constant, you can adjust the sensitivity of triggering, providing smoother experience