I’ve seen in some applications the layout shifts when soft keyboard is shown. This is certainly not adjustPan because the whole layout (probably inner layout) shifts, not only the current EditText. This is for instance in Evernote login screen. Can you advice how this made?
I’ve seen in some applications the layout shifts when soft keyboard is shown. This
Share
Here’s a solution that works like the Evernote login screen:
First, define a class that will be your special LinearLayout like this:
This layout listens to measure changes, and if new measurements are < than the old ones, that means part of the screen is eaten by soft keyboard.
Though, for it to work, in your manifest you need to set
android:windowSoftInputMode="adjustResize"so the content will be resized and not just shifted.And the whole system works as follows:
You have your layout:
It’s like evernotes login screen.
Then, in your activity:
Then go to manifest.xml and set
What will happen, is when soft keyboard is shown, it’ll hide the image and will resize the rest of content. (You can actually see how text is resized in Evernote)
Image hide is, of course, one of the many things you can do. But you must be careful, since different layout changes will also call onMeasure.
Of course it’s a dirty variant. You need to check for orientation changes, and the right time when actually take the measurements, and maybe some more logic when comparing the new specs with the old ones. But i think this is the only way to do it.