Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

android - ScrollView with Buttons inside, no response until second click on any button inside

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...