How to disable GridView scrolling in Android?
Try to add or override setOnTouchListener
for GridView
,
then in onTouch
method you can use code like this to
make gridView
not scrollable
Java
gridView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return event.getAction() == MotionEvent.ACTION_MOVE;
}
});
Kotlin
gridView.setOnTouchListener { v, event ->
event.action == MotionEvent.ACTION_MOVE
}
You can try setEnabled(false), although it might have other side effects. GridView is really not meant to be used the way you are using it. You should create your own custom view or layout. You could also use a TableLayout.