Reputation: 1059
I´m trying to put two views on my Activity, but I just need show them when the Keyboard is open. How can I do that?
I was looking for a tutorial or something but I find more about iOS than Android. Also I put a toolbar as the last one element on my layout, but it doesn´t work. I would like to know if exists something like "android:above_keyboard"... I don´t know.
Thanks.
Edid to add an example:
Upvotes: 5
Views: 2180
Reputation: 2119
You must implement a listener to catch when thekeyboard hides or shows:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks whether a hardware keyboard is available
if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
Log.d(getClass().getName(), "KEYBOARD VISIBLE");
yourView.setVisible(yourView.VISIBLE);
} else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
Log.d(getClass().getName(), "KEYBOARD HIDDEN");
yourView.setVisible(yourView.INVISIBLE);
}
}
Regarding the position of the last toolbar, I'm not sure what you mean. Could you elaborate further?
Upvotes: 4