mjtaryan Active Member Licensed User Longtime User Aug 20, 2013 #1 I am adding a panel to an app in code. The panel is not to have rounded corners. The default in the Designer is for a corner radius of 5. How can I change this programatically to 0? Thanks.
I am adding a panel to an app in code. The panel is not to have rounded corners. The default in the Designer is for a corner radius of 5. How can I change this programatically to 0? Thanks.
mangojack Expert Licensed User Longtime User Aug 21, 2013 #2 Hi .. Are you changing the panels background property ? .. Adding a panel in code results in no rounded corners here unless purposely set. This results in no rounded corners ... Code: Copy Dim Panel1 As Panel Panel1.Initialize("") Panel1.Color = Colors.Blue Activity.AddView(Panel1,20dip,20dip,300dip,300dip) This results in corner radius of 10 ... can be set to 0 if this is what your after .. Code: Copy Dim cd As ColorDrawable cd.Initialize(Colors.Blue,10) 'corner radius = 10 ... set to 0 for no rounded corner Dim Panel1 As Panel Panel1.Initialize("") Panel1.Background = cd Activity.AddView(Panel1,20dip,20dip,300dip,300dip) Cheers mj Last edited: Aug 21, 2013 Upvote 0
Hi .. Are you changing the panels background property ? .. Adding a panel in code results in no rounded corners here unless purposely set. This results in no rounded corners ... Code: Copy Dim Panel1 As Panel Panel1.Initialize("") Panel1.Color = Colors.Blue Activity.AddView(Panel1,20dip,20dip,300dip,300dip) This results in corner radius of 10 ... can be set to 0 if this is what your after .. Code: Copy Dim cd As ColorDrawable cd.Initialize(Colors.Blue,10) 'corner radius = 10 ... set to 0 for no rounded corner Dim Panel1 As Panel Panel1.Initialize("") Panel1.Background = cd Activity.AddView(Panel1,20dip,20dip,300dip,300dip) Cheers mj
mjtaryan Active Member Licensed User Longtime User Aug 21, 2013 #3 mangojack said: Hi .. Are you changing the panels background property ? .. Adding a panel in code results in no rounded corners here unless purposely set.... Click to expand... Thanks. I hadn't intended to change the background property, but I can. I was actually hoping for a more direct and straight forward method, but given that the corner radius property is only indirectly available in coding, your schema will work nicely. (It would be great if all the properties were available in both the Designer and through code - hint to Erel). Thanks again. Upvote 0
mangojack said: Hi .. Are you changing the panels background property ? .. Adding a panel in code results in no rounded corners here unless purposely set.... Click to expand... Thanks. I hadn't intended to change the background property, but I can. I was actually hoping for a more direct and straight forward method, but given that the corner radius property is only indirectly available in coding, your schema will work nicely. (It would be great if all the properties were available in both the Designer and through code - hint to Erel). Thanks again.
mangojack Expert Licensed User Longtime User Aug 22, 2013 #4 mjtaryan said: I am adding a panel to an app in code. The panel is not to have rounded corners. Click to expand... I'm confused ... if you add a panel by way of code by default it does NOT have rounded corners Code: Copy Dim Panel1 As Panel Panel1.Initialize("") Panel1.Color = Colors.Blue Activity.AddView(Panel1,20dip,20dip,300dip,300dip) Cheers mj Last edited: Aug 22, 2013 Upvote 0
mjtaryan said: I am adding a panel to an app in code. The panel is not to have rounded corners. Click to expand... I'm confused ... if you add a panel by way of code by default it does NOT have rounded corners Code: Copy Dim Panel1 As Panel Panel1.Initialize("") Panel1.Color = Colors.Blue Activity.AddView(Panel1,20dip,20dip,300dip,300dip) Cheers mj
dualznz Member Licensed User Longtime User Aug 22, 2013 #5 Code: Copy Dim cd AsColorDrawable cd.Initialize(Colors.Blue,10) 'corner radius = 10 ... set to 0 for no rounded cornerDim Panel1 AsPanel Panel1.Initialize("") Panel1.Background = cd Activity.AddView(Panel1,20dip,20dip,300dip,300dip) this is how you add a radius to the panel1. the code that you have provided is for a non cornered radius Code: Copy Dim Panel1 As Panel Panel1.Initialize("") Panel1.Color = Colors.Blue Activity.AddView(Panel1,20dip,20dip,300dip,300dip) Upvote 0
Code: Copy Dim cd AsColorDrawable cd.Initialize(Colors.Blue,10) 'corner radius = 10 ... set to 0 for no rounded cornerDim Panel1 AsPanel Panel1.Initialize("") Panel1.Background = cd Activity.AddView(Panel1,20dip,20dip,300dip,300dip) this is how you add a radius to the panel1. the code that you have provided is for a non cornered radius Code: Copy Dim Panel1 As Panel Panel1.Initialize("") Panel1.Color = Colors.Blue Activity.AddView(Panel1,20dip,20dip,300dip,300dip)
mangojack Expert Licensed User Longtime User Aug 22, 2013 #6 dualznz said: the code that you have provided is for a non cornered radius Click to expand... That is correct because ... mjtaryan said: I am adding a panel to an app in code. The panel is not to have rounded corners. Click to expand... "the panel is NOT to have rounded corners" ... maybe my first post #2 could have been clearer or am i missing something here .. ? Cheers mj Upvote 0
dualznz said: the code that you have provided is for a non cornered radius Click to expand... That is correct because ... mjtaryan said: I am adding a panel to an app in code. The panel is not to have rounded corners. Click to expand... "the panel is NOT to have rounded corners" ... maybe my first post #2 could have been clearer or am i missing something here .. ? Cheers mj
dualznz Member Licensed User Longtime User Aug 22, 2013 #7 no in your code u were only creating a rectangle box panel without any radius by default this is the case when coding the views when you add the Code: Copy Dim cd AsColorDrawable cd.Initialize(Colors.Blue,10) 'corner radius = 10 ... set to 0 for no rounded cornerDim Panel1 AsPanel it will then initialize a radius that will be attached to the panel view. ok so looking at your first post if you dont want a radius you can either just not initiate a radius to draw or just ad 0 then it wont add a radius to the panel Upvote 0
no in your code u were only creating a rectangle box panel without any radius by default this is the case when coding the views when you add the Code: Copy Dim cd AsColorDrawable cd.Initialize(Colors.Blue,10) 'corner radius = 10 ... set to 0 for no rounded cornerDim Panel1 AsPanel it will then initialize a radius that will be attached to the panel view. ok so looking at your first post if you dont want a radius you can either just not initiate a radius to draw or just ad 0 then it wont add a radius to the panel
mangojack Expert Licensed User Longtime User Aug 22, 2013 #8 dualznz said: no in your code u were only creating a rectangle box panel without any radius by default this is the case when coding the views Click to expand... Correct again .. because that is what mjtaryan wanted .. A panel WithOut any radius as I stated in #4 .. "if you add a panel by way of code by default it does NOT have rounded corners" thats it from me .. lol Cheers mj Upvote 0
dualznz said: no in your code u were only creating a rectangle box panel without any radius by default this is the case when coding the views Click to expand... Correct again .. because that is what mjtaryan wanted .. A panel WithOut any radius as I stated in #4 .. "if you add a panel by way of code by default it does NOT have rounded corners" thats it from me .. lol Cheers mj
mjtaryan Active Member Licensed User Longtime User Aug 23, 2013 #9 mangojack said: Correct again .. because that is what mjtaryan wanted .. A panel WithOut any radius as I stated in #4 .. "if you add a panel by way of code by default it does NOT have rounded corners" thats it from me .. lol Cheers mj Click to expand... I asked the original question because the Designer default is rounded corners with a radius of 5. Until now I've always added the panels I needed in the Designer and reset the radii to 0 there. I've not added a panel in code before and thought all the defaults from the Designer would carry over to code. That is why asked the question. However, my current project makes an array of panels more efficient which is more easily accomplished in code. Using the code snippet in post #2 (not the rounded corners) I did a little experimenting and discovered that only creating and initializing the panel and then adding it to its intended parent is all that is absolutely necessary to get corners with a radius of 0. Everything else is merely refinement. Therefore, for my purposes, I don't need to reset the panel's color property, which is shown in the snippet. Thanks for the help mj. I wish (hint to Erel) a) that all the properties could be set directly EITHER in the Designer or in code and b) the property defaults were consistent and the same whether set in the Designer or in code. But at least for now that is not the way it is. Upvote 0
mangojack said: Correct again .. because that is what mjtaryan wanted .. A panel WithOut any radius as I stated in #4 .. "if you add a panel by way of code by default it does NOT have rounded corners" thats it from me .. lol Cheers mj Click to expand... I asked the original question because the Designer default is rounded corners with a radius of 5. Until now I've always added the panels I needed in the Designer and reset the radii to 0 there. I've not added a panel in code before and thought all the defaults from the Designer would carry over to code. That is why asked the question. However, my current project makes an array of panels more efficient which is more easily accomplished in code. Using the code snippet in post #2 (not the rounded corners) I did a little experimenting and discovered that only creating and initializing the panel and then adding it to its intended parent is all that is absolutely necessary to get corners with a radius of 0. Everything else is merely refinement. Therefore, for my purposes, I don't need to reset the panel's color property, which is shown in the snippet. Thanks for the help mj. I wish (hint to Erel) a) that all the properties could be set directly EITHER in the Designer or in code and b) the property defaults were consistent and the same whether set in the Designer or in code. But at least for now that is not the way it is.