Sunday, April 10, 2011

How to enable fast scrolling in Android

Fast Scrolling in Android happens when you have a lot of items in your screen and you need to scroll fast. When it is activated you well see an small box coming from the right of the screen and when you drag it up or down it goes really fast. You can see this in your contact list, email or any application that has a lot of data and is sorted alphabetically.

There are 2 ways to enable this functionality in your application:
By adding the property in your XML layout file:


    <ListView
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fastScrollEnabled="true" />

or by adding it in your java code:

      getListView().setFastScrollEnabled(true);

Both of them work the same the only trick is that you need to have at least 35 items in your ListView in order to see the fast scrolling box. You can see the end result in the image.



Hope it helps some one, happy coding :)

4 comments:

  1. That's what I was searching.
    I have seen in iOS and some other platforms that here is a narrow column at extreme right side that contains alphabets and it it is overlay on the list view. Have you any idea?

    ReplyDelete
  2. thanks a lot. i did not guessed about 35 items and was wondering why it's not working.

    ReplyDelete