scrolling ListView within ScrollView

前端 未结 4 1373
终归单人心
终归单人心 2021-01-16 02:50

I have a ScrollView. One of its children is a ListView. Both scrolling in the same direction. How do I get both of them to respond to scroll events? And then when the end of

4条回答
  •  再見小時候
    2021-01-16 02:55

    you cannot add a ListView in a scroll View ,as list view also scolls and there would be a synchonization problem between listview scroll and scroll view scoll. You can make a CustomList View and add this method into it.

    @Override public boolean onInterceptTouchEvent(MotionEvent ev)
    {
        /*
         * Prevent parent controls from stealing our events once we've gotten a touch down
         */
        if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
            ViewParent p = getParent();
            if (p != null) {
                p.requestDisallowInterceptTouchEvent(true);
            }
        }
        return false;
    }
    

提交回复
热议问题