Skip to content Skip to sidebar Skip to footer

Autohide Scrollbars When Not Scrolling In A Listview

In the new official Twitter app, the scrollbars in all the ListViews the app uses are hidden unless the user is scrolling through the list. When you start scrolling, the scrollba

Solution 1:

Confirmed : either use android:fadeScrollbars ( if you're API level 5 ) or try to use setOnScrollListener to check scroll status and hide/show the bars . Some code examples are in this thread: how to detect Android ListView Scrolling stopped?

Solution 2:

You can enable scroll bar fading for your entire app on API level 5 and newer via a custom theme and the fadeScrollbars style attribute by adding this to styles.xml:

<stylename="Theme.App"parent="android:Theme.Light"><itemname="android:fadeScrollbars">true</item></style>

Then set the new theme for your application in AndroidManifest.xml:

<application android:icon="@drawable/app_icon" 
             android:label="@string/app_name"
             android:description="@string/description" 
             android:theme="@style/Theme.App"> 

Just be sure you're not overriding this global theme on individual activities. Earlier Android versions will safely ignore this unknown XML attribute and not fade the scrollbars.

Solution 3:

I haven't used them yet, but you might play around with android:scrollbarDefaultDelayBeforeFade and android:scrollbarFadeDuration, available on all widgets (i.e., subclasses of View).

Solution 4:

I followed Alex's answer and it worked using both the theme settings and through code.

GridViewgridview= (GridView) findViewById(R.id.mygridView);
gridview.setScrollbarFadingEnabled(false);

I did encounter a problem however with the Gallery Component. Whilst the following will compile fine, it will throw a NullPointerException. I assume this is to do with a Gallery not having scrollbars to show/hide.

Gallerygallery= (Gallery) findViewById(R.id.myGallery);
gallery.setScrollbarFadingEnabled(false); // <-- this will throw an exception

Android 2.2

Post a Comment for "Autohide Scrollbars When Not Scrolling In A Listview"