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:
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 ?
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).
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:
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.
Update: As several other libraries depend on xCustomListView library, it is no longer recommended to use the code module. Use the library instead. There are several extension classes that add more features to xCLV. They are listed at the end of this post. Video tutorial: xCustomListView is...
My starting point was indeed: https://www.b4x.com/android/forum/t...listview-cross-platform-customlistview.84501/
but that is fairly old and I am including the internal xCustomListView library v1.72 (as suggested there).
In looking to implement rounded corners I simply added SetColorAndBorder in the Sub that creates the list item for clv2.
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
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 ?
The method always works. Once you add the panel to CLV, CLV itself removes its background. Just add another transparent panel and everything will work.