Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Action bar hide/show while scrolling Listview in xamarin forms

$
0
0

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??


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>