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

后端 未结 4 665
-上瘾入骨i
-上瘾入骨i 2020-12-13 22:25

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 l

相关标签:
4条回答
  • 2020-12-13 22:53

    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 ?

    0 讨论(0)
  • 2020-12-13 22:57

    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.

    0 讨论(0)
  • 2020-12-13 22:58

    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.

    0 讨论(0)
  • 2020-12-13 23:05

    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...

    0 讨论(0)
提交回复
热议问题