Android Question B4XDialog Unclipped Corners + Out of line Buttons

epiCode

Active Member
Licensed User
1649168352256.png


How can I have clipped corners on top and buttons to not go out of the frame?

my code is like this

B4X:
    Dim opts As B4XListTemplate
    opts.Initialize
    opts.Options = Array As Double(0,1.0,1.5,2,3,4,5)
    Dim d As B4XDialog
    d.Initialize(Root)
    d.BlurBackground = False
    d.BorderCornersRadius = 20dip
    d.BackgroundColor = clrmeaning
    d.BodyTextColor = clrText
    d.Title = "Seconds "
    
    Dim sf As Object = d.ShowTemplate(opts, "Ok", "", "Cancel")
    Wait For (sf) Complete (Result As Int)
 

Alexander Stolte

Expert
Licensed User
Longtime User
call the SetCircleClip function with d.Base
B4X:
Private Sub SetCircleClip (pnl As B4XView,radius As Int)'ignore
#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 radius > 0 Then
    Dim d As Double = radius
    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(True))
    pnl.SetColorAndBorder(pnl.Color,0,0,radius)
    #Else If B4I
    Dim NaObj As NativeObject = pnl
    Dim BorderWidth As Float = NaObj.GetField("layer").GetField("borderWidth").AsNumber
    ' *** Get border color ***
    Dim noMe As NativeObject = Me
    Dim BorderUIColor As Int = noMe.UIColorToColor (noMe.RunMethod ("borderColor:", Array (pnl)))
    pnl.SetColorAndBorder(pnl.Color,BorderWidth,BorderUIColor,radius)
#end if
End Sub
 
Upvote 0
Top