Xamarin 101: How to Apply Android Fast Scroll in Xamarin Forms ListView

Are you looking for a sample of how to use Android fast scroll in Xamarin Forms?

Do you want to do it with only two lines of codes?

In this post, we will apply Android fast scroll in an existing demo app with ListView Grouping.

 

First things first, what could be the use case for using Fast Scroll on your Android? There are times that you would want your users to easily navigate long lists by providing them a draggable scroll bar in your ListView. So how do you do it? Just by writing two lines of codes. Note: iOS will ignore this tag and use a normal ListView UI.

 

Step 1:

Add an xmlns reference for the Assembly. I’ve written mine as androidSpecific as you can see in the screenshot below.

 

Step 2:

Then you need to add your ListView IsFastScrollEnabled property and set it to true.

 

Step 3:

Here is a sample of list-generating method that I’ve created to supply the necessary objects on my UI by including it in the OnAppearing method. If you don’t want to create yours, you can copy the mock data here from my GitHub.

https://github.com/webmasterdevlin/ListViewFastScroll/blob/master/ListViewFastScroll/ListViewFastScroll/MainPage.xaml.cs

Note: Your list must be long enough for you to be able to see the effect of Fast Scroll on your Android

 

ListView with Grouping in XAML

Step 4:

Lastly, build and run your sample app.

Here’s a GIF animation of a normal ListView and a ListView with Fast Scroll in Android enabled.

Fast Scroll Not Enabled

Look at the scrollbar.

Fast Scroll Enabled

Did you notice the scroll bar?

See the difference? It is super easy to set it up, right? You may see the full source code here https://github.com/webmasterdevlin/ListViewFastScroll

If you haven’t tried creating any ListView with Grouping yet, the GitHub URL above will also show you how to do it.

So, until next time. Try it so you can learn it quickly. Happy coding!



Post A Comment