Android Question Move buttons position when keyboard is opened

Mattiaf

Active Member
Licensed User
is there a way to move buttons positions at runtime just a bit above of the keyboard when typing on a edit text?
thanks
 

LucaMs

Expert
Licensed User
Longtime User
Use the IME library.

Declare a class-level (Class_Globals) variable of type IME and use the HeightChanged event:
B4X:
Private IME1 As IME

B4X:
Private Sub IME1_HeightChanged (NewHeight As Int, OldHeight As Int)
    If NewHeight = 0 Then Return ' If useful
    Button1.Top = NewHeight - Button1.Height
End Sub
 
Last edited:
Upvote 1

Mattiaf

Active Member
Licensed User
hmm it doesn't seems to work or maybe i'm doing something wrong...
I'm clicking into an edit text, the keyboard appears, but the button is not relocating above the keyboard..
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
hmm it doesn't seems to work or maybe i'm doing something wrong...
I'm clicking into an edit text, the keyboard appears, but the button is not relocating above the keyboard..
Try the example attached to the official thread about IME:
https://www.b4x.com/android/forum/t...-keyboard-with-the-ime-library.14832/#content

You will see that the btnHideKeyboard button is moved above the keyboard in the IME_HeightChanged event, just like I suggested.

This won't work if you set the Activity to full screen, due to an Android bug that was never fixed! :mad:
 
Upvote 0
Top