Question

I've been a couple of days trying to solve this thing but I can't figure it out. The problem is, simple activity, with simple layout, ScrollView -> LinearLayout -> and a lot of buttons inside the layout (within the scroll content). Everything works just fine, but one tricky thing. When I click a button, let's say at the top of the scroll content and immediately scroll down to the bottom of the content and click another button there, nothing happens until I click a second time and all comes to normal again. This can be reproduced anytime and it's code independent (I've tried more than 20 scenarios). I don't have much experience in Android yet, but looks like the scroll listener stops the onClick listener or something like that. Any help with this would be much appreciated. Thank you in advance.

PD. If I programmatically do a scrollTo(), instead of manual scroll with my fingers, everything works just fine and the click responds at first touch. It's simply overwhelming me.

Was it helpful?

Solution

Everything is behaving normally.

When you start scrolling, the ScrollView will claim touch events until you stop touching the screen for a bit. In Android 2.2, you will know when scrolling is deemed complete, because the scrollbar on the right will fade away.

OTHER TIPS

I have the same problem. I disagree that it's a fading scrollbar issue. If you disable the fading, the same thing happens.

Tried several approaches in themes.xml:

<item name="android:scrollbarDefaultDelayBeforeFade">100</item>
<item name="android:scrollbarFadeDuration">100</item>
<item name="android:fadeScrollbars">true</item>

But nothing helped. It seems that it's a system thing with scrollViews. This might help to see what's going on:

setOnScrollListener(new OnScrollListener(){
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
      // TODO Auto-generated method stub
    }
    public void onScrollStateChanged(AbsListView view, int scrollState) {
      // TODO Auto-generated method stub
      if(scrollState == 0) Log.i("a", "scrolling stopped...");
    }
  });
}

But that (unfortunately) doesn't help in overcoming the problem - but rather explaining it.

NOTE: this only happens if you use ScrollView. ListView doesn't have this problem.

Anyone has another idea ?

I got a situation like this. I have a ExpandableListView, it just behaves normally. When I rotate the cellphone to horizontal, and rotate back, then some items in one group of the ExpandableListView will not responding for click event. Unless I scroll the list view, or click the group item of these items, the event will dispatch to the items I clicked previously, and perform the click listener codes correctly.

This happened both in android 2.3 and 4.0...

I've been able to fix this by overriding onScrollChanged, then sending the ScrollView a MotionEvent via OnTouchEvent when the bounds are reached to simulate a user touch.

It's the hackiest, dirtiest programming I can imagine, but it works ok in my application. This app is for phones running 2.2 only, and this bug needed to be fixed somehow.

If anyone has a better solution please let me know.

Edit: This problem is only in 2.2 btw, they've fixed it in 2.3, and it wasn't an issue in 2.1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top