Android Question Panel in CustomListView not roundable

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, as always on Android the "UI problems" are more than iOS...
I filled a CLV with this code

B4X:
    For Each p As Map In pasti
        clvDiete.Add(CreateListItem(n, i), n)
    Next

B4X:
Sub CreateListItem(Text As String, ImageName As String) As Panel
    Dim p As B4XView
    p = xui.CreatePanel("")
  
    p.Top = 0
    p.Left = 0
    p.Width = clvDiete.AsView.Width
    p.Height = 200dip
    'p.LoadLayout("element_Pasto") 'Commented for testing
    p.Color = Colors.Red
    p.SetColorAndBorder(p.Color, 1dip, Colors.Black, 40dip) 'want to round the panel
    'lblTitlePasto.SetColorAndBorder(lblTitlePasto.Color, 1dip, 0xFF00C482, 10dip)

    'lblTitlePasto.Text = Text
  
    p.Top = 0
    p.Left = 0
    p.Width = clvDiete.AsView.Width

    Return p
End Sub
Screenshot_20210609_113913_b4a.example.jpg

I tried to round the corners of the single panel, but as you can see only the border follows the idea, the red filling is going out intead.. why this happends?Thanks in advance guys
 

Attachments

  • Screenshot_20210609_113913_b4a.example.jpg
    Screenshot_20210609_113913_b4a.example.jpg
    94.7 KB · Views: 114

Mike1970

Well-Known Member
Licensed User
Longtime User
Thats because on Android the child views hat not the same behavior as the parent, that means if your parent panel ist round, then the child views can overlap the parent. To fix this, you need this code:
B4X:
Dim jo As JavaObject = pnl
jo.RunMethod("setClipToOutline", Array(True))
pnl.SetColorAndBorder(pnl.Color,0,0,radius)
Oh wow, this means that with this code it behave like on iOS?
in the example "pnl" is the child or the parent?

Edit: I tried, the answer is "the Parent"
I did not know it could be done. Awesome. Thanks :D
 
Last edited:
Upvote 0
Top