4

I just want to show the scrollbar for 2 sec when view is created. Is there any attribute for this?

Actually it show when user touch the screen but I want to show it automatically for a few seconds so user can know this view is scroll-able.

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbarDefaultDelayBeforeFade="2000"
    android:scrollbarAlwaysDrawVerticalTrack="true">
Arslan Anwar
  • 18,746
  • 19
  • 76
  • 105

3 Answers3

3

You can either:

  • Make a call to move the scrollView (e.g. mScrollView.scrollBy(0, 1)) if you don't mind the view scrolling by a pixel. This will call through to onScrollChanged and subsequently awaken the scroll bars. If you call something like scrollBy(0, 0), the scrollView realizes it doesn't need to do anything and won't shown the scroll bars.

  • Create a subclass of ScrollView the publicly exposes the awakenScrollBars() method, which is protected by default. See here for details.

greg7gkb
  • 4,933
  • 4
  • 41
  • 55
  • Thanks! I did the trick this way: `mScrollView.scrollBy(0, -1); mScrollView.scrollBy(0, 1);` That is the shortest solution I think – alaster Oct 12 '13 at 13:18
2

add the android:id attribute in the xml for ScrollView and in the activity use timer or countdowntimer for 2 sec notification and on completion set the visibility of the ScrollView to invisible.

Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • He, I am not asking for hiding the ScrollView. But only the scroll-bar of the ScrollView. Actually it show when user touch the screen but I want to show it automatically for a few seconds so user can know this view is scroll-able. – Arslan Anwar Aug 16 '11 at 08:58
  • after showing scrollbar for 2 secs set this property to your view: yourview.setScrollbarFadingEnabled(true); – Vineet Shukla Aug 16 '11 at 09:06
  • Mean I have to do this using code. Ok. If I did not find any other good solution I will implement this code. Thanks – Arslan Anwar Aug 16 '11 at 09:12
0

check out this link(android:scrollbarFadeDuration)

http://developer.android.com/reference/android/view/View.html#attr_android:scrollbarFadeDuration

or try this..

android:fadeScrollbars="true"
ShineDown
  • 1,881
  • 3
  • 21
  • 29