tags:

views:

233

answers:

2

How to do the following stuffs in ListView

  1. Only show scroll bar when user flip the list.

    By default, if the list is more than the screen, there is always a scrollbar on the right side.

    Is there a way to set this scrollbar only shows when user flip the list?

  2. Keep showing the list background image when scrolling.

    I've set an image as the background of the ListView, but when I scroll the list, the background image will disappear and only shows a black list view background.

    Is there any way to keep showing the list background image when scrolling?

  3. Don't show the shadow indicator.

    When the list has more items to display, there is a black-blur shadow to indicate user that there are more items. Is there a way to remove this item?

+2  A: 

The issue with the black background is easy to fix. It's an issue with the cacheColorHint - a way to tell Android what the background color of your list is so that it can more easily create the "fading edge" at the top and bottom of your list when the user is scrolling. However, if your background isn't a solid color then the cacheColorHint does more harm than good. See this post from the Android developer's blog for more information. The way to fix it is just to add this to your ListView xml:

android:cacheColorHint="#00000000"

You can change that color code to whatever you want; it's in AARRGGBB format, also sometimes known as HTML color codes but with an extra 2 digits in front for transparency.

As for removing the scrollbar unless the user is actually scrolling, I'm not sure. Experiment with the various android:scrollbar... settings. If you're using Eclipse, you can type out android:scrollbar and then hit ctrl + spacebar to make it suggest options.

Steve H
Thanks, but I still haven't got luck with any android:scrollbar..s
Johnny
+2  A: 

You can just turn scrollbars on and off using setVerticalScrollbarEnabled(). The "shadow" indicator is called the fading edge in our APIs. There are various methods to control the fading edges in the base View class.

Romain Guy