Android Question Problem with Custom View & InputType->made Virtual Keyboard covered Input Area

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have a problem with EditText InputType in Custom View.

I have a layout with 2 Custom View, this Custom View basically is an EditText with border.

When I ran the app on a small screen (4 inch), here what happen on the second Custom View
1) if this Custom View is not in focused & clicked, this view raised up when Virtual Keyboard appeared, this is the expected result, I set this code in manifest editor
B4X:
SetActivityAttribute(Main, android:windowSoftInputMode, "adjustPan|stateHidden")

2) but if this Custom View is in focused & clicked, Virtual Keyboard appeared, but Custom view didn't raise up, so it was covered by Virtual Keyboard

I have tried to locate the problem & found out that is was caused by a call to an InputType on this sub on my Custom View codes
B4X:
Public Sub setFieldType(Typ As Byte)
    FldTyp = Typ
    If(FldTyp = TypeText) Then
        edt.Gravity = Gravity.LEFT+Gravity.CENTER_VERTICAL
        edt.InputType = InpTypFirstCap 'this is the caused of a problem
    else If(FldTyp = TypeInt Or FldTyp = TypeFloat Or FldTyp = TypeCurrency) Then
        edt.Gravity = Gravity.RIGHT+Gravity.CENTER_VERTICAL
        edt.Text = 0
    End If
End Sub

If I removed that line, it will behaved as expected, but Next/Done disappeared from Virtual Keyboard.

Can anyone helps me to fix this problem? Attached is a sample project to this problem.
Thanks in advance.
 

Attachments

  • sample.zip
    9.4 KB · Views: 298

incendio

Well-Known Member
Licensed User
Longtime User
You should position the cursor on the second field immediately, not by press next button from first field, then when virtual keyboard appeared, click back button to dismis the keyboard, and then click again this second field to make virtual keyboard appear again, this time the problem will shows.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
That's strange. I have tested on real device with JellyBean and on Genymotion with Lollipop 5.0, both shows same anomaly.

Attached is the screen shot on Lollipop. The cursor is in the second field and screen didn't pan when virtual keyboard shows.
 

Attachments

  • Err.jpg
    Err.jpg
    105.4 KB · Views: 317
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
The issue was very similar to my problem, but not sure it was the same problem.

I have tested on Android before Android N, these are the result
1) setting gravity without InputType -> works OK
2) setting InputType without Gravity -> works OK
3) setting InputType + Gravity -> not OK

Do another test again, this time, replaced the field with just a simple EditText & applied InputType & Gravity, and it works OK on Android M & below.

On my case this issue only appears when use Custom View + InputType + Gravity. EditText + InputType + Gravity won't cause a problem.
 
Upvote 0
Top