Wish B4XDialog - Fix Title Bar when rounding dialog corners

MrKim

Well-Known Member
Licensed User
Longtime User
Experimenting with B4XDialog
Tried Rounding the corners but the title bar doesn't look professional.
B4X:
    dialog.Base.SetColorAndBorder(xui.Color_Blue, 2, xui.Color_Black, 20)

1621186229481.png

So I tried adding this line:
B4X:
dialog.TitleBar.SetColorAndBorder(xui.Color_Red, 0, 0, 20)

It's better but it just doesn't look right. Can the upper corners of the Title be hidden?

1621186784567.png
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    dialog.Initialize(Root)
    dialog.Title = "Hello"
    dialog.TitleBarColor = xui.Color_Red
    dialog.BorderCornersRadius = 20dip
    dialog.BorderWidth = 1
End Sub

Private Sub Button1_Click
    Dim rs As Object = dialog.Show("asdasdasd", "ok", "", "")
    UpdateClip(dialog.Base, dialog.BorderCornersRadius)
    Wait For (rs) Complete (Result As Int)
End Sub

Private Sub UpdateClip (pnl As B4XView, CornersRadius As Int)
#if B4J
    Dim jo As JavaObject = pnl
    Dim shape As JavaObject
    Dim cx As Double = pnl.Width
    Dim cy As Double = pnl.Height
    shape.InitializeNewInstance("javafx.scene.shape.Rectangle", Array(cx, cy))
    If CornersRadius > 0 Then
        Dim d As Double = CornersRadius * 2
        shape.RunMethod("setArcHeight", Array(d))
        shape.RunMethod("setArcWidth", Array(d))
    End If
    jo.RunMethod("setClip", Array(shape))
#else if B4A
    Dim jo As JavaObject = pnl
    jo.RunMethod("setClipToOutline", Array(CornersRadius > 0))
#end if
End Sub
 
Top