I think there are two kinds of “focus” here:
- Pressing EditText is necessary to provide exactly one receiver for keyboard events.
- The keyboard focus, that is, the keyboard is visible and the keys can be pressed.
As far as I understand, in android only FocusText gets focus. The keyboard works in the service and receives touch events thanks to the special Insets class.
If you only need to increase the visibility of your keyboard, you should try the answers to this question .
EDIT
I think there are two ways to do this, depending on whether you want this keyboard to be activity specific or accessible everywhere.
As far as I understand, the inputmethodservice method, which is responsible for showing the keyboard, will not allow you to achieve this.
My best advice is that you create a specialized keyboard view that has this "focus key" feature (an extended keyboard would be a good starting point).
You can change the keyboard visibility (using View.VISIBLE and View.GONE) so that it looks and disappears.
Then you must enter your own behavior to select the key with focus and move it accordingly.
In your activity, you will also need to remember the last EditText in which it would be concentrated in order to send him text or keyCodes.
If you want this behavior to be available throughout the system, you must provide your inputmethodservice . I advise you to take a look at this post as well as the SoftKeyboard sample in the SDK.
Please note that you also need to create your own KeyboardView, as described above, but without having to remember the focus of the EditText.
source share