Moving panel above a keyboard

syncmaster13

Member
Licensed User
Longtime User
Hi

I have two panels in my activity view. One is on the top and one in the bottom. In both of them I have few edit text views. How I Can move up the bottom panel up when the keyboard shows up? . In my case keyboard cover the panel.
Thank You
 

syncmaster13

Member
Licensed User
Longtime User
Thank for replay

Now when I click on edittext view which is a part of bottom panel, entire panel moves up (when keyboard shows up). Unfortunately it happens also when I click on edittext view which belongs to top panel. When it happens bottom panel covers top panel and I have no more access to top one.
 
Upvote 0

syncmaster13

Member
Licensed User
Longtime User
I have no idea what You just said.:BangHead: I’ve read about IME library but it is still a little confusing.

Can I ask You for an example. Some code with 2 panels and 2 edittext views? (one for each panel).

Thank You
 
Upvote 0

syncmaster13

Member
Licensed User
Longtime User
I made a simple example. Two panels with 2 edit text views. My goal is to move bottom panel so it covers top one, when keyboard is activated.
Thank You
 

Attachments

  • move_panel_up.zip
    7 KB · Views: 366
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Globals
   Dim IME As IME
   Dim pnl_top As Panel
   Dim pnl_bottom As Panel    
   Dim edt_text_top As EditText
   Dim edt_text_bottom As EditText
   Dim focusedEditText As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
   IME.Initialize("IME")
   IME.AddHeightChangedEvent
   Activity.LoadLayout("Layout1")

End Sub

Sub IME_HeightChanged (NewHeight As Int, OldHeight As Int)
   If focusedEditText = edt_text_bottom Then
      If NewHeight < OldHeight Then
         pnl_bottom.Top = 0
      Else
         pnl_bottom.Top = 50%y
      End If
   End If
End Sub


Sub edt_text_top_FocusChanged (HasFocus As Boolean)
   If HasFocus Then focusedEditText = Sender   
End Sub
Sub edt_text_bottom_FocusChanged (HasFocus As Boolean)
   'note that you can use the same sub by setting the EventName of the EditTexts
   If HasFocus Then focusedEditText = Sender
End Sub
 
Upvote 0

dwsands

Member
Licensed User
Longtime User
I'm not sure this is the right place to post this but this is where I found my answer.

From experimenting it seems that wherever you give any view a .visible = false the edittext view will not slide (don't know if that is the right term) above the keyboard. If you don't touch the .visible, Android seems to handle the slide by itself. The fix was to use the IME library and change the height of the panel the views are on. Changes to the manifest and other suggestions on working around this issue did not work.

My comment/question is that this seems to be a bug in .visible or is this a feature? My project doesn't need the IME library and the associated coding except to handle this .visible issue.

Thanks...David
 
Upvote 0
Top