Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable gallery scroll view on Android

I use Gallery to show photos.
And it can scroll to previous or next one by touch screen.
But I want to set a button to lock the gallery.
I use below code to implement it:

gallery.setEnabled(false);

But it still can scroll view by touch screen.
How can I arrive it?

like image 726
brian Avatar asked Feb 04 '26 18:02

brian


1 Answers

override the onTouchListner for your gallery

gallery.setOnTouchListener(new OnTouchListener() {

  @Override
  public boolean onTouch(View v, MotionEvent event) {

     return true;
  }
 });
like image 77
Blackbelt Avatar answered Feb 07 '26 08:02

Blackbelt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!