简体   繁体   English

ListView滚动在scrollView内部不起作用 它创造了混蛋

[英]ListView scrolling not working inside scrollView. it is creating jerk

i have integrated listView inside the scrollView. 我已经将listView集成在scrollView中。 im facing issue while vertical scrolling. 我在垂直滚动时面临问题。 how to fix this issue ? 如何解决这个问题?

ListView inside the scrollView is an bad programming practice. scrollView内的ListView是不好的编程习惯。 ListView aleary has its own scrolling functionality and you are again embedding it into the scrollView that why it is creating an jerk. ListView aleary具有其自己的滚动功能,您再次将其嵌入到scrollView中,这就是为什么它产生了冲击。

Don't use listView inside the scrollView. 不要在scrollView中使用listView。

If you want to scroll let's say listView and not whole scrollView you could try this code. 如果要滚动,请说listView而不是整个scrollView,可以尝试以下代码。 However, it is not good idea to place listView inside of scrollview. 但是,将listView放在scrollview内不是一个好主意。 Your users may find it uncomfortable. 您的用户可能会觉得不舒服。

yourListView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (v.getId() == R.id.yourListView) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
            switch (event.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_UP:
                    v.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
            }
        }
        return false;
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM