HorizontalScrollView within ScrollView Touch Handling

前端 未结 8 1802
轮回少年
轮回少年 2020-11-22 05:28

I have a ScrollView that surrounds my entire layout so that the entire screen is scrollable. The first element I have in this ScrollView is a HorizontalScrollView block tha

8条回答
  •  悲&欢浪女
    2020-11-22 05:57

    I've found out that somethimes one ScrollView regains focus and the other loses focus. You can prevent that, by only granting one of the scrollView focus:

        scrollView1= (ScrollView) findViewById(R.id.scrollscroll);
        scrollView1.setAdapter(adapter);
        scrollView1.setOnTouchListener(new View.OnTouchListener() {
    
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                scrollView1.getParent().requestDisallowInterceptTouchEvent(true);
                return false;
            }
        });
    

提交回复
热议问题