Android Question IME - Activity does not scroll automatically

LucaMs

Expert
Licensed User
Longtime User
I attach Erel's example, published by him in the thread dedicated to the IDE library, slightly modified by me. I only commented what was not necessary for this demonstration and moved EditText4 down.

ime.Show(EditText4) shows the virtual keyboard but the Activity is not automatically moved up as it should.

I also attached a project with the same layout but not a B4XPages project; same problem.
 

Attachments

  • IME_Example_Modified.zip
    10.5 KB · Views: 41
  • IME_Example_No_B4XPages.zip
    9.8 KB · Views: 43
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Another project, without any line of code, not even in the Manifest, without IME library, just a layout with two B4XFloatTextField positioned near the bottom edge of the variant, works, the Activity automatically goes up.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've just tried the IME example: https://www.b4x.com/android/forum/t...-keyboard-with-the-ime-library.14832/#content
It works. When the soft input mode is set to adjustResize then it is your responsibility to update the layout. This is done with this code:
B4X:
Private Sub IME_HeightChanged (NewHeight As Int, OldHeight As Int)
    btnHideKeyboard.Top = NewHeight - btnHideKeyboard.Height
    EditText1.Height = btnHideKeyboard.Top - EditText1.Top
End Sub

The other option is adjustPan. With adjustPan you let the OS handle it for you. Sometimes it works. Sometimes it doesn't.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Sometimes it works. Sometimes it doesn't.
I guess it depends on the device.

On my smartphone it is not even necessary to add adjustPan, the automatic scrolling happens without any addition to Manfest and without IME. But, as usual, it was not for me and on the device of another B4X member this does not happen.

Since it is not possible to know a priori whether the automatic scrolling will happen, I will try a "nice" thing:
a B4XDialog with B4XInputTemplate, positioned above the keyboard and temporarily moving the B4XFloatTextField in the dialog.


Thanks Erel.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The other option is adjustPan. With adjustPan you let the OS handle it for you. Sometimes it works. Sometimes it doesn't.
For those who still don't like B4XPages projects 😊 ...

Due to the fact that in these projects the layout is in the Root panel, I solved by moving it up when necessary ("working" on ime_HeightChanged, ftf_FocusChanged (ftf = event name of B4XFloatTextFields), keeping the "current" FTF).
 
Last edited:
Upvote 0
Top