Android Question How to create curved bottom border rectangle in android?

Erel

B4X founder
Staff member
Licensed User
Longtime User


B4X:
Private Sub CreateBackground (pnl As B4XView)
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, pnl.Width, pnl.Height)
    Dim cvs As B4XCanvas
    cvs.Initialize(p)
    cvs.DrawCircle(p.Width / 2, 0, p.Height, 0xFFFF5B5B, True, 0)
    Dim iv As B4XImageView = XUIViewsUtils.CreateB4XImageView
    pnl.AddView(iv.mBase, 0, 0, pnl.Width, pnl.Height)
    iv.mBackgroundColor = xui.Color_Transparent
    iv.Bitmap = cvs.CreateBitmap
    iv.mbase.SendToBack
    pnl.Color = xui.Color_Transparent
    cvs.Release
End Sub

If you are using it multiple times then it will be more efficient to reuse the canvas.
 
Upvote 0

ArminKh1993

Active Member
Fantastic, Thank you
 
Upvote 0

ArminKh1993

Active Member
Can u please help me to clear transparent area?
I want just filled area
i want some thing like clipToOutline method
or some thing to remove extra path
imagine this is a panel and have curved bottom and i add some viewes to this panel
then clipToOutline will not works
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Save canvas to use in other views
Dim bmp As B4XBitmap = CreateBackground
B4X:
    Dim bmp As B4XBitmap = CreateBackground
    
    B4XImageView1.SetBitmap(bmp)
    B4XImageView1.mBase.Color = xui.Color_Transparent
    B4XImageView2.SetBitmap(bmp)
    B4XImageView2.mBase.Color = xui.Color_Transparent
    
    Dim iv As B4XImageView = XUIViewsUtils.CreateB4XImageView
    Pane1.AddView(iv.mBase, 0, 0, Pane1.Width, Pane1.Height)
    iv.mBackgroundColor = xui.Color_Transparent
    iv.Bitmap = bmp
    iv.mbase.SendToBack
    Pane1.Color = xui.Color_Transparent

B4X:
Public Sub CreateBackground As B4XBitmap
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 600, 600)
    Dim cvs As B4XCanvas
    cvs.Initialize(p)
    cvs.DrawCircle(p.Width / 2, 0, p.Height, 0xFFFF5B5B, True, 0)
    cvs.Release
    Return cvs.CreateBitmap
End Sub

sample:
 
Upvote 0

ArminKh1993

Active Member
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…