Android HorizontalScrollView disable scrolling

前端 未结 2 846
闹比i
闹比i 2020-12-20 18:27

I have HorizontalScrollView with long view as a child, so HorizontalScrollView is scrollable and can scroll its child horizontally. Is there any possibility to block that?

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 18:47

    My suggestion is to use an OnTouchListener, for example:

    In onCreate Method


    HorziontalScrollView scrollView= (HorizontalScrollView)findViewById(R.id.scrollView);
    scrollView.setOnTouchListener(new OnTouch());
    

    And has a class:


    private class OnTouch implements OnTouchListener
    {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
        return true;
        }
    }
    

提交回复
热议问题