Android Question Panel with rounded corners not as expected

ShepSoft

Member
Licensed User
This code:

Rounded panel:
Dim DateHdrPanel As B4XView = xui.CreatePanel("")
DateHdrPanel.SetLayoutAnimated(0, 0, 0, 100%x, 40dip)
DateHdrPanel.SetColorAndBorder(Colors.Blue,2dip,Colors.Yellow,20dip)

Produces this output:
Q.jpg

when I would expect (wish) it to constrain its background within its rounded boundary.
Can I create a Panel with rounded corners where the b/g is constrained within the corners
without resorting to low-level drawing routines ?
 

ShepSoft

Member
Licensed User
Yes indeed it can - a plain old Panel works fine.
But does that mean that the Xui code I offered is broken in this respect?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
worked for me. only difference was i added the view to the activity (missing from your code). tried with and without setanimation (no difference). tried with a bunch of different colors behind the panel (including nothing behind). no difference. apologies for the crummy image, but if you look hard, you'll see the blue is constrained as desired (and expected).
 

Attachments

  • panel.png
    panel.png
    6.7 KB · Views: 158
Upvote 0

ShepSoft

Member
Licensed User
Thanks for your comment drgottjr.

However, the issue seems to relate to the xCustomListView.
My code given in the first post in this thread was added to a custom list view:
Round cornered panel in custom list view:
Dim DateHdrPanel As B4XView = xui.CreatePanel("")
DateHdrPanel.SetLayoutAnimated(0, 0, 0, 100%x, 40dip)
DateHdrPanel.SetColorAndBorder(Colors.Blue,2dip,Colors.Yellow,20dip)
clv.Add(DateHdrPanel, "dhpname")
which doesn't work with the visual result shown above.
However, if as you suggest, I simply add it as a child of Activity:
Round cornered panel as child of Activity:
Dim DateHdrPanel As B4XView = xui.CreatePanel("")
DateHdrPanel.SetLayoutAnimated(0, 0, 0, 100%x, 40dip)
DateHdrPanel.SetColorAndBorder(Colors.Blue,2dip,Colors.Yellow,20dip)
Activity.AddView(DateHdrPanel,5dip,5dip,95%x,35dip)
then it works and looks like this:
Q2.jpg

So the question is: how do I get this code working to add instances of it to a custom list view? With properly rounded corners.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i don't mind trying it with a clv. it would be helpful to know what other unseen code you're not mentioning.
 
Upvote 0

ShepSoft

Member
Licensed User
I am merely trying the xCustomListView example on B4X.com and attempting to get it to use rounded corners.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I am merely trying the xCustomListView example on B4X.com and attempting to get it to use rounded corners.
Hiya,
Could you please link to the example you're talking about, there are quite a few on here.

Are you looking at this example???

Thank you...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
So the question is: how do I get this code working to add instances of it to a custom list view? With properly rounded corners.
1. Do whatever you can with the visual designer. Things will be simpler and it will be easy to port the layout to other platforms.
2. Create an item layout and add a panel with round corners.
B4X:
For i = 1 to 100
 Dim pnl As B4XView = XUI.CreatePanel("")
 pnl.SetLayoutAnimated(0, 0, 0, clv.AsView.Width, 100dip) 'change height as needed
 pnl.LoadLayout("ItemLayout")
 CLV.Add(pnl, "")
Next
 
Upvote 0

ShepSoft

Member
Licensed User
Thank you, and your advice in point 1 is well taken.
But am I right in my understanding that although SetColorAndBorder is available as a method for setting round corners on a Panel it does not work correctly where the Panel is a child of a CustomListView ?
 
Upvote 0

ShepSoft

Member
Licensed User
Thanks again - I didn't know that CLV removes panel backgrounds by design.
 
Upvote 0
Top