tags:

views:

578

answers:

4

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 scrollbars appear. When you stop, they fade out with an animation until they are gone completely.

I can't seem to find anything in the documentation that indicates this as being a standard feature.

Is this something included in the API? If not, anyone know how this might be done?

+1  A: 

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).

CommonsWare
that might work, if coupled with setScrollbarFadingEnabled(boolean) API level 5 - xml attribute is android:fadeScrollbars
Alex Volovoy
+2  A: 

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: http://stackoverflow.com/questions/1768391/how-to-detect-android-listview-scrolling-stopped

Alex Volovoy
+2  A: 

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:

 <style name="Theme.App" parent="android:Theme.Light">
    <item name="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.

Alex Pretzlav