We are trying to implement Action bar Hide/Show functionality while scrolling recyclerView in Android by using following code.
RecyclerView.SetOnScrollListener(new HideShowScrollListener());
public class HideShowScrollListener : RecyclerView.OnScrollListener
{
private int HIDE_THRESHOLD = 20;
private int scrolledDistance = 0;
private bool controlsVisible = true;
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
{
base.OnScrolled (recyclerView, dx, dy);
if (scrolledDistance > HIDE_THRESHOLD && controlsVisible) {
(Forms.Context as Android.App.Activity).ActionBar.Hide ();
controlsVisible = false;
scrolledDistance = 0;
} else if (scrolledDistance < -HIDE_THRESHOLD && !controlsVisible) {
(Forms.Context as Android.App.Activity).ActionBar.Show ();
controlsVisible = true;
scrolledDistance = 0;
}
if((controlsVisible && dy>0) || (!controlsVisible && dy<0)) {
scrolledDistance += dy;
}
}
}
We are able to achieve the same the functionality but we are facing flickering issues while hiding/show action bar.
Any help??