ShepSoft Member Licensed User Jun 22, 2020 #1 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: 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 ?
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: 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 ?
Peter Simpson Expert Licensed User Longtime User Jun 22, 2020 #2 A panel with rounded corners can be created in the designer without the one single line of code being written Attachments download.jpg 10.7 KB · Views: 333 Upvote 0
A panel with rounded corners can be created in the designer without the one single line of code being written
ShepSoft Member Licensed User Jun 22, 2020 #3 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
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?
drgottjr Expert Licensed User Longtime User Jun 22, 2020 #4 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 6.7 KB · Views: 366 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).
ShepSoft Member Licensed User Jun 22, 2020 #5 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: 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
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: 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.
drgottjr Expert Licensed User Longtime User Jun 22, 2020 #6 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 don't mind trying it with a clv. it would be helpful to know what other unseen code you're not mentioning.
ShepSoft Member Licensed User Jun 22, 2020 #7 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.
Peter Simpson Expert Licensed User Longtime User Jun 22, 2020 #8 ShepSoft said: I am merely trying the xCustomListView example on B4X.com and attempting to get it to use rounded corners. Click to expand... 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??? [B4X] [XUI] xCustomListView - cross platform CustomListView 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... www.b4x.com Thank you... Upvote 0
ShepSoft said: I am merely trying the xCustomListView example on B4X.com and attempting to get it to use rounded corners. Click to expand... 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??? [B4X] [XUI] xCustomListView - cross platform CustomListView 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... www.b4x.com Thank you...
ShepSoft Member Licensed User Jun 22, 2020 #9 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. Upvote 0
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.
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2020 #10 ShepSoft said: 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. Click to expand... 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
ShepSoft said: 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. Click to expand... 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
ShepSoft Member Licensed User Jun 23, 2020 #11 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
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 ?
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2020 #12 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. Upvote 0
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.
ShepSoft Member Licensed User Jun 23, 2020 #13 Thanks again - I didn't know that CLV removes panel backgrounds by design. Upvote 0