Android Question Keyboard height

Tayfur

Well-Known Member
Licensed User
Longtime User
hello everbody;

My poroblem is ;
Keyboard show when I focused/touched textbox. So I can see textbox. Because keybord front of textbox.
I know answer, and i must move up textbox. So How much move???

I must learn 2 value;
1-keybord is showed?
2-Keyboard height or top value?
waiting your tips.
thank you



Screenshot_2016-02-05-08-17-31.png
 

LucaMs

Expert
Licensed User
Longtime User
Store initial Panel1.Top in a Global variable (mPanel1Top)

B4X:
Sub IME1_HeightChanged(NewHeight As Int, OldHeight As Int)
    Dim KeyboardVisible As Boolean
    KeyboardVisible = (NewHeight < OldHeight)
  
    If Not(KeyboardVisible) Then
        Panel1.Top = mPanel1Top
    Else
        Dim AbsEditTextTop As Int = Panel1.Top + EditText1.Top
        Panel1.Top = mPanel1Top - (AbsEditTextTop - NewHeight)
    End If
End Sub


NOT TESTED
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
NOT TESTED

In fact, it is wrong, you have to consider EditText "bottom", not the top.

B4X:
Sub IME1_HeightChanged(NewHeight As Int, OldHeight As Int)
    Dim KeyboardVisible As Boolean
    KeyboardVisible = (NewHeight < OldHeight)

    If Not(KeyboardVisible) Then
        Panel1.Top = mPanel1Top
    Else
        Dim AbsEditTextBottom As Int = Panel1.Top + EditText1.Top + EditText1.Height
        Panel1.Top = mPanel1Top - (AbsEditTextBottom - NewHeight)
    End If
End Sub

AGAIN, NOT TESTED :D
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
thank you for fedback @LucaMs

my code is works fine now.

B4X:
Sub EditText_to_FocusChanged (HasFocus As Boolean)
    EditText_to.Tag=HasFocus
    EditText_subject.Tag=Not(HasFocus)
    If Button_mail_send.Tag < 100%y And  HasFocus Then
        If Panel_mail.Top+EditText_to.Top+EditText_to.Height>Button_mail_send.Tag Then
                Panel_mail.Top=Panel_mail.Top+(Button_mail_send.Tag-(Panel_mail.Top+EditText_to.Top+EditText_to.Height))
            End If
    End If
End Sub
Sub EditText_subject_FocusChanged (HasFocus As Boolean)
    EditText_to.Tag=Not(HasFocus)
    EditText_subject.Tag=(HasFocus)
    If Button_mail_send.Tag < 100%y And  HasFocus Then
            If Panel_mail.Top+EditText_subject.Top+EditText_subject.Height>Button_mail_send.Tag Then
                Panel_mail.Top=Panel_mail.Top+(Button_mail_send.Tag-(Panel_mail.Top+EditText_subject.Top+EditText_subject.Height))
            End If
    End If
End Sub



Sub IME1_HeightChanged (NewHeight As Int, OldHeight As Int)
  
Button_mail_send.Tag=NewHeight
  
    If Panel_mail.Visible And NewHeight<100%y Then ' panel görünür ve dipten yukarıdadır.
      
        If EditText_to.Tag Then
            'Msgbox("to:" & NewHeight&"-"&100%y," TO için yukseklik")
            If Panel_mail.Top+EditText_to.Top+EditText_to.Height>NewHeight Then
                Panel_mail.Top=Panel_mail.Top+(NewHeight-(Panel_mail.Top+EditText_to.Top+EditText_to.Height))
            End If
        End If
        '-------------------------------------
        If EditText_subject.tag Then
            If Panel_mail.Top+EditText_subject.Top+EditText_subject.Height>NewHeight Then
                Panel_mail.Top=Panel_mail.Top+(NewHeight-(Panel_mail.Top+EditText_subject.Top+EditText_subject.Height))
            End If
        End If
    End If
  
    If Panel_mail.Visible And NewHeight=100%y Then ' panel görünür ve dipten yukarıdadır.
        Panel_mail.Top=Panel_mail.Tag
    End If
  
  
End Sub
 
Upvote 0
Top