简体   繁体   中英

Android Studio ScrollView in ScrollView

I'm working on an App with Android Studio(Java) and want a ScrollView inside a ScrollView.

If I scroll the small one to the end it automatically starts scrolling the big one, is it possibile to disable the scrolling function of the big one when scolling the small one?

You need to handle this by disabling the other ScrollView when scrolling the current one

Let's say you have scroll_view_parent and scroll_view_child

parentScrollView.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            findViewById(R.id.scroll_view_child).getParent()
                    .requestDisallowInterceptTouchEvent(false);
            return false;
        }
    });

childScrollView.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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