Hi!
I'm stuck. I'd like to know if there's a way to obtain an image with rounded corners.
Doesn't mind the type of control Imageview, button, pane...
I've tried a button with background image and CSS with
But if I load an image, the rounded corners do not appear anywhere
A little code to explain better:
Result:
I've used the CSSUtils.SetBorder property to show the fail properly.
I've also seen the following B4A code from https://www.b4x.com/android/forum/t...e-on-a-round-corners-panel-how.60310/#content , but I don't know to translate it to B4J actually:
Any help, indication, suggestion... will be welcome!!
Sorry for my english, and Thanks in advance.
I'm stuck. I'd like to know if there's a way to obtain an image with rounded corners.
Doesn't mind the type of control Imageview, button, pane...
I've tried a button with background image and CSS with
B4X:
CSSUtils.SetStyleProperty(Button1,"-fx-background-radius","8")
A little code to explain better:
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Button1 As Button
Private Pane1 As Pane
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
Dim path As String = GetSystemProperty("user.home", "")
Button1.Initialize("Button1")
Pane1.Initialize("Pane1")
MainForm.RootPane.AddNode(Button1, 50,50,100,100)
MainForm.RootPane.AddNode(Pane1, 50,350,100,100)
If File.Exists(path & "\Pictures","incredibles.png") Then
CSSUtils.SetBackgroundImage(Button1,path & "\Pictures","incredibles.png")
CSSUtils.SetBackgroundImage(Pane1,path & "\Pictures","incredibles.png")
End If
CSSUtils.SetBorder(Button1,2,fx.Colors.Blue,10)
CSSUtils.SetStyleProperty(Button1,"background-repeat","stretch")
CSSUtils.SetStyleProperty(Button1,"-fx-background-radius","8")
CSSUtils.SetBorder(Pane1,2,fx.Colors.Blue,10)
CSSUtils.SetStyleProperty(Pane1,"background-repeat","stretch")
MainForm.Show
End Sub
Result:

I've used the CSSUtils.SetBorder property to show the fail properly.
I've also seen the following B4A code from https://www.b4x.com/android/forum/t...e-on-a-round-corners-panel-how.60310/#content , but I don't know to translate it to B4J actually:
B4X:
Sub AssignBitmapToPanelWithRoundBorders( P As Panel, B0 As Bitmap, radius As Int)
Dim B1,B2 As Bitmap
Dim cv As Canvas
Dim Rect1 As Rect
B2.InitializeMutable(P.Width,P.Height)
cv.Initialize2(B2)
Dim Drawable1 As ColorDrawable
Drawable1.Initialize(Colors.White,radius)
Rect1.Initialize(0,0,B2.Width-1,B2.Height-1)
cv.DrawDrawable(Drawable1,Rect1)
B1.InitializeMutable(P.Width,P.Height)
cv.Initialize2(B1)
cv.DrawBitmap(B0,Null,Rect1)
For r=0 To B2.Height-1
For c=0 To B2.Width-1
If B2.GetPixel(c,r)=0 Then
cv.DrawPoint(c,r,0)
End If
Next
Next
P.SetBackgroundImage(B1)
End Sub
Any help, indication, suggestion... will be welcome!!
Sorry for my english, and Thanks in advance.