How to create an on-screen android keyboard that isnt a rectangle at the bottom portion of the screen?

StackOverflow https://stackoverflow.com/questions/4082721

Question

I want to develop a replacement keyboard, but I am afraid that Android assumes the general keyboard 'area' will be a single rectangular shape that sits at the bottom of the screen.

What if I want my keyboard to consist of multiple shapes that don't just sit at the bottom of the screen? Am I doomed from the start, or is it possible to do what I want to do?

On a related note, what if I only want my keyboard to appear when the phone is in a certain orientation but when the phone is held at a different orientation, the normal soft keyboard is used? Again, out of luck or possible?

cheers!

Was it helpful?

Solution

The IME is just a window. It is positioned relative to the bottom of the screen, so you can't really control that. But you can draw whatever you want in it, or not for places you want to be transparent. You can control how much applications move up away from your IME with this: http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html#onComputeInsets(android.inputmethodservice.InputMethodService.Insets)

Android doesn't let windows decide one at a time whether events will be handled by them or dispatched to the window behind them; the only control you have to keep events from being consumed by your entire window is the Insets.touchableInsets constants to tell the window manager to allow events outside of the given insets to go through to what is behind it.

OTHER TIPS

Presumably you could create a rectangle where ever you want and make bits of it transparent. Not sure how to pass UI events to the activity below your keyboard though.

Anyway, there's a softkeyboard sample that will probably be Quite Helpful.

As I see it there are two ways you might handle the UI Thing. - Pass events off to the underlying activity when they "should go through"... As your softkeyboard may have its own process, this could get a bit thorny. - Make your keyboard up of more than one rectangular region, such that the UI events pass through Naturally. I'm not sure if that's even possible. I'm still fairly new to Android development myself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top