I'm quite new to Android native development, and I'm trying to figure out how to customize the IME action buttons. I've looked at the Google documentation, but I can find very few information about the expected behaviour.
From the offical guide I understand that the keyboard action button can be configured using the attributes:
- android:imeOptions can set the text/id of the button displayed near the space key to some pre-defined values (E.g. actionGo set the key label to Go and the id to 2)
- android:imeActionLabel set the label of the button displayed inside the input area when the keyboard is fullscreen, usually in landscape mode. Can be set to any string value.
- android:imeActionId same as previous but set the numeric Id passed to the callback method
But after some empiric attempts I've found different behaviour between API level 15 and next API levels.
I've set up a simple EditText element with the following attributes:
<EditText
...
android:imeOptions="actionGo"
android:imeActionLabel="Custom"
android:imeActionId="666"
android:inputType="text"/>
and I've checked the effect with the different API levels both in portrait and landscape mode. Here is the outcome.
API level 15 - 4.0.3
In portrait mode the key label is Go and the action id passed to the callback method is 2, accordingly to the imeOptions setting.
In landscape mode the key label/id is Go/2 as the portrait mode, while the button displayed in the input area is Custom/666, accordingly to the imeActionLabel and imeActionId attributes.
API level 16, 17 and 18 - 4.1.2, 4.2.2 and 4.3
Both in portrait and landscape mode the key and the button are displayed with Custom label and are bound to 666 id, ignoring imeOptions attribute.
This mismatch in the behaviour is quite annoying because:
- with API level >= 16 you can't distinguish between key button and input area button
- with API level = 15 you can't set any custom text for key button.
Do you know how to obtain this both in API 15 and 16+? Or if there is a way to obtain a consistent behaviour across all (or at least a part of) the API versions?
Maybe I am missing something in the IME settings that can justify the different behaviour...
Thank you very much!