B4A Library [B4X] [XUI] B4XDialog - Custom dialogs

Not open for further replies.
Edit: B4XDialogs is part of XUI Views library. Use that instead: [B4X] XUI Views - Cross platform views and dialogs

B4XDialog class helps with creating cross platform custom dialogs. The dialog is made of a simple panel and it is therefore completely customizable.


Simple usage (change Activity with MainForm.RootPane or Page1.RootPanel or any other panel you like):
Sub ShowDialog
   Dim p As B4XView = xui.CreatePanel("")
   p.SetLayoutAnimated(0, 0, 0, 300dip, 170dip) 'set the content size
   Dim rs As ResumableSub = Dialog.Show(Activity, p, "Ok", "", "Cancel")
   Wait For (rs) Complete (Result As Int)
   If Result = xui.DialogResponse_Positive Then
       'do something
   End If
End Sub

In most cases it requires a bit more work as you also want to handle keyboard changes:
Sub ime_HeightChanged (NewHeight As Int, OldHeight As Int)
   If Dialog.Visible Then Dialog.Resize(100%x, NewHeight)
End Sub
Sub Page1_KeyboardStateChanged (Height As Float)
   If Dialog.Visible Then Dialog.Resize(Page1.RootPanel.Width, Page1.RootPanel.Height - Height)
End Sub
And in B4A you can handle the back key:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
   If KeyCode = KeyCodes.KEYCODE_BACK And Dialog.Visible Then
       Return True
   End If
   Return False
End Sub

The attached B4A example shows how to access the default buttons and change their state based on the forms fields.

B4XDialog class is included in the example.

- XUI / iXUI / jXUI
- BitmapCreator v4.50+ (copy to the internal library folder if needed)
Last edited:


Staff member
Licensed User
V1.10 released with a few changes:

- Blurring of the background. This is an optional feature. It is enabled by default in B4A and B4J and disabled in B4i (the snapshot call is a bit slow in B4i).
- Other small changes.


- Don't call AutoScaleAll in the dialog layout. It will not work as expected as the layout is loaded to a smaller panel.
- I encountered issues with FloatLabeledEditText in B4A and the keyboard handling. I recommend using regular EditTexts instead inside the dialog.
- BitmapCreator v4.50+ is required. Link for v4.50 is available above.
Last edited:


Licensed User
Do you have a running example in B4I?
Did you follow the link given on the first line (the bold one) of the first post in this thread? The example in that thread (the replacement for this one) includes B4A, B4i and B4J examples.
Not open for further replies.