Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autohide scrollbars when not scrolling in a ListView

Tags:

android

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?

like image 663
synic Avatar asked May 17 '10 19:05

synic


People also ask

Are scrollbars necessary?

There are some reasons to use a scroll bar, but the main one is because we need to allow to focus on one specific area at a time. Content overload is well known in the field of user experience and using this small component in the UI improves the way we split users' attention.

How do I hide the scroll bar in inactivity?

There are many ways to hide the scroll bar when the page is inactive. One such way is using the onscroll, onmousewheel, onclick and onmousemove events, which help us to achieve our goal using basic HTML and JavaScript. Approach: The onscroll event is used to disable the scroll bar.

What is automatically hide scrollbars in Windows?

The Windows operating system hides scroll bars that are not hovered over by the pointer when running UWP applications by default. This feature is great for people who like to scroll through the internet using their mouse wheel and could not care less about the scroll bar.


2 Answers

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?

like image 126
Alex Volovoy Avatar answered Nov 07 '22 07:11

Alex Volovoy


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.

like image 25
Alex Pretzlav Avatar answered Nov 07 '22 05:11

Alex Pretzlav