ListView nested scrolling on API<21

后端 未结 3 2278
长情又很酷
长情又很酷 2020-12-06 18:00

Title is clear. I\'m having this layout:

_________________
|_______________| <- Toolbar    
|___|___|___|___| <- Tablayout
|               |
|                  


        
相关标签:
3条回答
  • 2020-12-06 18:38

    Unfortunately, there is no way to get nested scrolling working on ListView - otherwise it wouldn't require the modifications that were done in API 21.

    You'll note that the current Parse SDK has actually removed ParseQueryAdapter entirely. Given that, it may make sense to start building your own RecyclerView based adapter using the Parse query APIs directly.

    0 讨论(0)
  • 2020-12-06 18:50

    For those intersted in the specific ParseQueryAdapter issue,

    • Guys at parse.com are working on a RecyclerView.Adapter version;

    • There's a beta version of it.

    0 讨论(0)
  • 2020-12-06 18:59

    I'm actually a Xamarin developer so I can't test if this works in this particular case, but I found an answer which helped me in Xamarin, so I'm gonna share it:

    I found a solution that works excellently and can scroll the ListView without problems:

    ListView lv = (ListView)findViewById(R.id.myListView);  // your
    listview inside scrollview lv.setOnTouchListener(new
    ListView.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            switch (action) {
            case MotionEvent.ACTION_DOWN:
                // Disallow ScrollView to intercept touch events.
                v.getParent().requestDisallowInterceptTouchEvent(true);
                break;
    
            case MotionEvent.ACTION_UP:
                // Allow ScrollView to intercept touch events.
                v.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }
    
            // Handle ListView touch events.
            v.onTouchEvent(event);
            return true;
        }
    });
    

    What this does is disable the TouchEvents on the ScrollView and make the ListView intercept them. It is simple and works all the time.

    If this won't work, please tell me so I can delete this answer. But maybe it helps anyone since I also found this question and it seems to have no solution.

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