Hi,
It seems like the OS will automatically scroll the sv to make sure the focused edittext is visible to the user, so I took a slightly different approach in a solution:
I first created a routine that will search for a view's parent scroll view. This way I didn't need a bunch of DIM's for all the different scrollviews in order to be able to work with just one of them.
Sub GetParentScrollView (V As View) As Object
'returns the scrollview that is parent to the passed view (or returns non scrollview object if not found/error)
'this allows accessing a particular scrollview from among many contained in an activity without requiring a unique declaration for each scrollview
Dim FoundIt As Boolean = False
Do While FoundIt = False
Dim P As Object
Try
P = V.parent
Catch
Return P
End Try
If P Is ScrollView Then
FoundIt = True
Else
V = P
End If
Loop
Return P
End Sub
Then I have this code in the keyboard event:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
Dim R As Object
Select Case tabIcon.CurrentPage
Case 0
R = Misc.GetParentScrollView(txtName)
Case 2
R = Misc.GetParentScrollView(txtTextMessage)
End Select
If R Is ScrollView Then
sv = R
sv.Height = NewHeight - ActionBar.Height - 50dip 'tab header height
End If
End Sub
I was actually surprised to see that you also used a constant of '50' for the tab height when calculating the scrollview height because there is no "tabMain.height" property to use in a calculation. My thought was that using a fixed value would not be a good value to depend on because it could vary from device to device. But I guess it's not.