diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index 4d97b76e90a475..57d47d2956a42b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -18,6 +18,7 @@ import androidx.core.view.ViewCompat; import androidx.core.text.TextUtilsCompat; import android.util.Log; +import android.view.KeyEvent; import android.view.FocusFinder; import android.view.MotionEvent; import android.view.View; @@ -411,6 +412,16 @@ public boolean onTouchEvent(MotionEvent ev) { return super.onTouchEvent(ev); } + @Override + public boolean executeKeyEvent(KeyEvent event) { + int eventKeyCode = event.getKeyCode(); + if (!mScrollEnabled && (eventKeyCode == KeyEvent.KEYCODE_DPAD_LEFT || + eventKeyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) { + return false; + } + return super.executeKeyEvent(event); + } + @Override public void fling(int velocityX) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index de0fc82ee66b27..b2126d6debe968 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -14,6 +14,7 @@ import android.graphics.drawable.Drawable; import androidx.core.view.ViewCompat; import android.util.Log; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -300,6 +301,16 @@ public boolean onTouchEvent(MotionEvent ev) { return super.onTouchEvent(ev); } + @Override + public boolean executeKeyEvent(KeyEvent event) { + int eventKeyCode = event.getKeyCode(); + if (!mScrollEnabled && (eventKeyCode == KeyEvent.KEYCODE_DPAD_UP || + eventKeyCode == KeyEvent.KEYCODE_DPAD_DOWN)) { + return false; + } + return super.executeKeyEvent(event); + } + @Override public void setRemoveClippedSubviews(boolean removeClippedSubviews) { if (removeClippedSubviews && mClippingRect == null) {