Android Question IME Event Problem

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi,
I'm getting a problem with IME_HeightChanged event... in an Activity, I used
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden) to maintain a textbox visible... but I noticed that I need to maintain other objects visible on the screen also... then I decided to capture IME event and measure the soft keyboard height in order to resize the screen objects.
I used the code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
...

    IME1.Initialize("IME")
    IME1.AddHeightChangedEvent
...

Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)

    Log("softkeyboard " & NewHeight)
    ToastMessageShow(NewHeight,True)

End Sub

But when I inserted the capture of IME event:
- The textbox is hidden by softkeyboard
- The event IME_HeightChanged isn't raised

As the event isn't raised it's not possible to resize or move the textbox or any other screen objects... before adding IME1.AddHeightChangedEvent the textbox were automatically moved to the top of softkeyboard (but I couldn't reallocate or resize any other screen object because I didn't have the event ... but after, no event, no move...)

any suggestion?
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
There are two modes:
adjustPan: the os pushes the activity when the keyboard opens.
adjustResize: the os doesn't do anything.

You can either choose to let the OS handle it for you or adjust the layout yourself.
Ok, @Erel , but: how can I detect that the soft keyboard is being showed, and get the new screen size, in order to be able to reallocate objects if needed ? (for example, suppose that I use adjustPan and want to maintain a header on the screen. How can I do this?
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
You can only get the resize event with adjustResize mode. The IME example shows how to handle the event.
The event is not being generated, I think that it's because the activity has in manifest SetActivityAttribute(main, android:windowSoftInputMode, adjustPan|stateHidden) ... I'll test and post here. Thanks!
 
Upvote 0
Top