其他分享
首页 > 其他分享> > Android 按键 修复在全部应用下,↓键可以实现下移

Android 按键 修复在全部应用下,↓键可以实现下移

作者:互联网

frameworks/base/core/java/android/view/ViewRootImpl.java

private boolean performFocusNavigation(KeyEvent event) {
 switch (event.getKeyCode()) {
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    if (event.hasNoModifiers()) {
                        direction = View.FOCUS_LEFT;
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    if (event.hasNoModifiers()) {
                        direction = View.FOCUS_RIGHT;
                    }
                    break;
                case KeyEvent.KEYCODE_DPAD_UP:
                    if (event.hasNoModifiers()) {
                        direction = View.FOCUS_UP;
                    }
                    break;
+                case KeyEvent.KEYCODE_DPAD_DOWN:
+                    //wangrui For Settings.apk, let the ↓ key have the function of selecting the first-level directory. In other cases, the ↓ key will be performed in the default way.
+                    if (!("com.android.settings".equals(cn.getPackageName()))){
+                        if (event.hasNoModifiers()) {
+                            direction = View.FOCUS_DOWN;
+                        }
+                        break;
+                    }
                case KeyEvent.KEYCODE_TAB:
                    if (event.hasNoModifiers()) {
                        direction = View.FOCUS_FORWARD;
                    } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                        direction = View.FOCUS_BACKWARD;
                    }
                    break;
            }
}

标签:direction,KeyEvent,FOCUS,KEYCODE,按键,下移,Android,event,View
来源: https://blog.csdn.net/qq_27494201/article/details/121919694