The key to this is onComputeInsets of the InputMethodService. It's been a while since I've done this, but if I remember right you make the visible insets the entire screen and you make the content insets 0. This makes you able to draw to the entire screen but will make the app you're typing to not pan or resize at all. The touchable insets should be set to region with a rect that covers the area you want to draw to.
When you draw the view, make sure that any part of the screen you don't want to cover is drawn with TRANSPARENT so the background app shows through. The easiest way to do this is to make a custom view that's onDraw draws all transparent, then draws the keyboard where it needs to be.