Android Question B4XInputTemplate position

leitor79

Active Member
Licensed User
Longtime User
Hi,

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:

B4X:
        input.Initialize
        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!
 

Erel

B4X founder
Staff member
Licensed User
Longtime 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:
B4X:
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)
 
Upvote 0
Top