Closed DeanWookey closed 3 years ago
I see Attach has a keyboard service with functionality to get the keyboard height. I'll look into using that instead.
Currently on Android there is no interaction between the JavaFX view with the keyboard view, so that's why the KeyboardService provides some API that you can use in several ways.
If you want to move the view, so the TextField/TextArea controls are not overlapped by the software keyboard, you can use keepVisibilityForNode
(code).
If you want to react to the software keyboard showing up in any way, you can use visibleHeightProperty
(code). For a given height value > 0, you can decide to move the whole view up or you can decide to stretch it, while with value 0, you will restore its original position/dimensions.
Note this service also applies in the exact same way to iOS.
@jperedadnr Thanks. It works much better than the MainActivity hack.
In our case it's preferable for the stage to resize smaller when the keyboard is shown rather than overlapping the elements, including the ones you're inputting into to.
Supposedly there is a way to do that by editing the manifest by adding
ie.
This apparently doesn't work with a translucent status bar? It also works as intended, so there doesn't seem to be much chance of a fix coming from the Android side. Anyway, there are lots of stackoverflow issues about this with a whole variety of solutions:
As a proof of concept, I edited my MainActivity and ran gradlew app:assembleDebug manually with one of the solutions, which seems to somewhat work (it's a bit flickery). I think one option would be to allow you to specify your own MainActivity in src/android in the same way you can specify your own AndroidManfiest (which I couldn't find any documentation for by the way) so that people wouldn't have to do what I did. The downside is that any fixes/changes you made to those auto generated files would have to be integrated manually.
Another option would be to more formally support this functionality.
If we could detect the keyboard was showing somehow we could also do this on the javafx side by adding appropriate padding to the root element.