Android Question Panel with rounded corners not as expected

ShepSoft

Member
Licensed User
This code:

Code:
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 ?
 
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
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: 366
Upvote 0
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:
Code:
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:
Code:
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
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
I am merely trying the xCustomListView example on B4X.com and attempting to get it to use rounded corners.
 
Upvote 0
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
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.
Code:
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
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
Thanks again - I didn't know that CLV removes panel backgrounds by design.
 
Upvote 0
Back
Top