Hi Erel,I recommend using SimpleMediaManager for this: https://www.b4x.com/android/forum/t...rk-for-images-videos-and-more.134716/#content
With SMM you can make the image round by setting REQUEST_ROUNDIMAGE: True.
Making the parent panel corners round should affect the image as well.
Sub setCornerRadius(v As View, Rx_TopLeft As Float, Ry_TopLeft As Float, Rx_TopRight As Float, Ry_TopRight As Float, Rx_BottomRight As Float, Ry_BottomRight As Float, Rx_BottomLeft As Float, Ry_BottomLeft As Float)
Dim jo As JavaObject = v.Background
If v.Background Is ColorDrawable Or v.Background Is GradientDrawable Then
jo.RunMethod("setCornerRadii", Array As Object(Array As Float(Rx_TopLeft, Ry_TopLeft, Rx_TopRight, Ry_TopRight, Rx_BottomRight, Ry_BottomRight, Rx_BottomLeft, Ry_BottomLeft)))
End If
End Sub
What I truly meant is that SMM is cross platform, written in B4X and is better for B4X developers. So if OP needs help with implementing such feature I can help if he implements it with SMM
"Erel, I haven't worked with SMM before, but I used the following code for testing. So, could you tell me how I can customize the radius of each corner of my image?"Why RecyclerView???
Create a new project. With SMM and CustomListView. Once you get it working I can help you with setting the corners.
Sub Globals
Dim MediaManager As SimpleMediaManager
Private Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
MediaManager.Initialize
Dim extra As Map = CreateMap(MediaManager.REQUEST_ROUNDIMAGE: True, MediaManager.REQUEST_BACKGROUND: xui.Color_White)
MediaManager.SetMediaWithExtra(Panel1, "https://downloadscdn6.freepik.com/1340/32/31672.jpg?filename=bunch-flowers-with-pink-yellow-background.jpg&token=exp=1727266960~hmac=48c3abfe28987e766e4d38ee4d5f5799&filename=31672.jpg", "", extra)
End Sub
1. Why aren't you using B4XPages?
2. If are setting REQUEST_ROUNDIMAGE: True then you will get a round image.
3. Call setCornerRadius to set the corners of Panel1.
4. Set MediaManager.REQUEST_RESIZE_MODE to FILL or FILL_NO_DISTORTIONS.
Sub Globals
Dim MediaManager As SimpleMediaManager
Private Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
MediaManager.Initialize
Dim extra As Map = CreateMap(MediaManager.REQUEST_ROUNDIMAGE: True, MediaManager.REQUEST_BACKGROUND: xui.Color_Green, MediaManager.REQUEST_RESIZE_MODE : "FILL_NO_DISTORTIONS")
MediaManager.SetMediaWithExtra(Panel1, "https://i.ibb.co/cYy2CKB/mov-94214-1826821-ezgif-com-webp-to-jpg-converter.jpg", "", extra)
setCornerRadius(Panel1,50,50,50,50,50,50,50,50)
End Sub
Sub setCornerRadius(v As View, Rx_TopLeft As Float, Ry_TopLeft As Float, Rx_TopRight As Float, Ry_TopRight As Float, Rx_BottomRight As Float, Ry_BottomRight As Float, Rx_BottomLeft As Float, Ry_BottomLeft As Float)
Dim jo As JavaObject = v.Background
If v.Background Is ColorDrawable Or v.Background Is GradientDrawable Then
jo.RunMethod("setCornerRadii", Array As Object(Array As Float(Rx_TopLeft, Ry_TopLeft, Rx_TopRight, Ry_TopRight, Rx_BottomRight, Ry_BottomRight, Rx_BottomLeft, Ry_BottomLeft)))
End If
End Sub
Remove REQUEST_ROUNDIMAGE
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private smm As SimpleMediaManager
Private Panel1 As B4XView
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
smm.Initialize
SetImageWithRoundCorners(Panel1, "https://s8.uupload.ir/files/mov_94214_1826821-ezgif.com-webp-to-jpg-converter_01x.jpg")
End Sub
Private Sub SetImageWithRoundCorners (Target As B4XView, Url As String)
Target.Visible = False
smm.SetMediaWithExtra(Target, Url, "", CreateMap(smm.REQUEST_CALLBACK: Me, smm.REQUEST_RESIZE_MODE: "FILL_NO_DISTORTIONS"))
Wait For (Panel1) SMM_MediaReady (Success As Boolean, Media As SMMedia)
If Success Then
If Panel1.Getview(0).Tag Is B4XImageView Then
Dim iv As B4XImageView = Panel1.Getview(0).Tag
setCornerRadius(iv.mBase, 5dip, 5dip, 10dip, 10dip, 20dip, 20dip, 40dip, 40dip)
iv.mBase.As(JavaObject).RunMethod("setClipToOutline", Array(True))
Target.SetVisibleAnimated(300, True)
End If
End If
End Sub
Private Sub setCornerRadius(v As View, Rx_TopLeft As Float, Ry_TopLeft As Float, Rx_TopRight As Float, Ry_TopRight As Float, Rx_BottomRight As Float, Ry_BottomRight As Float, Rx_BottomLeft As Float, Ry_BottomLeft As Float)
Dim jo As JavaObject = v.Background
If v.Background Is ColorDrawable Or v.Background Is GradientDrawable Then
jo.RunMethod("setCornerRadii", Array As Object(Array As Float(Rx_TopLeft, Ry_TopLeft, Rx_TopRight, Ry_TopRight, Rx_BottomRight, Ry_BottomRight, Rx_BottomLeft, Ry_BottomLeft)))
End If
End Sub
I haven't checked your example. It is your choice to waste time with activities.
Full example:
B4X:Sub Class_Globals Private Root As B4XView Private xui As XUI Private smm As SimpleMediaManager Private Panel1 As B4XView End Sub Public Sub Initialize End Sub Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("MainPage") smm.Initialize SetImageWithRoundCorners(Panel1, "https://s8.uupload.ir/files/mov_94214_1826821-ezgif.com-webp-to-jpg-converter_01x.jpg") End Sub Private Sub SetImageWithRoundCorners (Target As B4XView, Url As String) Target.Visible = False smm.SetMediaWithExtra(Target, Url, "", CreateMap(smm.REQUEST_CALLBACK: Me, smm.REQUEST_RESIZE_MODE: "FILL_NO_DISTORTIONS")) Wait For (Panel1) SMM_MediaReady (Success As Boolean, Media As SMMedia) If Success Then If Panel1.Getview(0).Tag Is B4XImageView Then Dim iv As B4XImageView = Panel1.Getview(0).Tag setCornerRadius(iv.mBase, 5dip, 5dip, 10dip, 10dip, 20dip, 20dip, 40dip, 40dip) iv.mBase.As(JavaObject).RunMethod("setClipToOutline", Array(True)) Target.SetVisibleAnimated(300, True) End If End If End Sub Private Sub setCornerRadius(v As View, Rx_TopLeft As Float, Ry_TopLeft As Float, Rx_TopRight As Float, Ry_TopRight As Float, Rx_BottomRight As Float, Ry_BottomRight As Float, Rx_BottomLeft As Float, Ry_BottomLeft As Float) Dim jo As JavaObject = v.Background If v.Background Is ColorDrawable Or v.Background Is GradientDrawable Then jo.RunMethod("setCornerRadii", Array As Object(Array As Float(Rx_TopLeft, Ry_TopLeft, Rx_TopRight, Ry_TopRight, Rx_BottomRight, Ry_BottomRight, Rx_BottomLeft, Ry_BottomLeft))) End If End Sub
View attachment 157322