I haven't tried this, but here is one possibility:
Let's say you add a custom attribute to your custom view. Let's call it "imeVisible".
layout/view.xml:
...
app:imeVisible="false"
...
layout-keysexposed/view.xml:
...
app:imeVisible="true"
...
I am assuming the system will generate a configuration change for IME show/hide when you have something in layout-keysexposed
, because normally it doesn't.
But it will do a layout change (adjustResize
), so another more generic approach would be to just override onLayout()
in your custom view:
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
int height = b - t;
// logic here for different heights
}