Android Question B4XInputTemplate position


Active Member
Licensed User

I'm using an imput template, but it is show at top, where I have some buttons, and part of the input dialog is hidden. I'd like to show it a little bit centered, but without having to use a custom layout.

This is my code:

        input.lblTitle.Text = "Title"
        Wait For (dialog.ShowTemplate(input, "OK", "", "CANCELAR")) Complete (Result As Int)
        If Result = xui.DialogResponse_Positive Then
            Dim res As Int = input.Text 'no need to check with IsNumber
            Log("producto: " & res)
        End If
I've tried input.GetPanel(dialog).Top = 150dip, before the showtemplate, but it makes no difference.

Thank you!


Staff member
Licensed User
It is related to the B4XDialog.PutAtTop property that is set automatically when you use the input template. However there is a reason for this. If the dialog will be centered the keyboard will hide the dialog (at least on smaller devices).

You can change the dialog's top position like this:
Dim rs As ResumableSub = Dialog.ShowTemplate(InputTemplate, "OK", "", "CANCEL")
Dialog.Base.Top = 50%y - Dialog.Base.Height / 2
Wait For (rs) Complete (Result As Int)