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 scrollin
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?
I followed Alex's answer and it worked using both the theme settings and through code.
GridView gridview = (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.
Gallery gallery = (Gallery) findViewById(R.id.myGallery);
gallery.setScrollbarFadingEnabled(false); // <-- this will throw an exception
Android 2.2
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
).
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.