J Jerryk Active Member Licensed User Longtime User Nov 19, 2024 #1 In connection with using the MeasureStringWidth function, I need to correct the calculation of Padding and Border Width that are set on the Label. I get the current padding values from lbl.Padding. I haven't found any function to get the current Border value. The opposite function for SetColorAndBorder. Is it possible to get these values?
In connection with using the MeasureStringWidth function, I need to correct the calculation of Padding and Border Width that are set on the Label. I get the current padding values from lbl.Padding. I haven't found any function to get the current Border value. The opposite function for SetColorAndBorder. Is it possible to get these values?
Solution J J Jerryk Nov 20, 2024 I found a solution. Since the code is used inside DesignerCreateView I have to use B4X: Dim LabelBorder As ColorDrawable LabelBorder = mBase.Background Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) Log(jo.GetField("borderColor")) Log(jo.GetField("cornerRadius"))
I found a solution. Since the code is used inside DesignerCreateView I have to use B4X: Dim LabelBorder As ColorDrawable LabelBorder = mBase.Background Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) Log(jo.GetField("borderColor")) Log(jo.GetField("cornerRadius"))
mangojack Expert Licensed User Longtime User Nov 20, 2024 #2 Possible solution from snippets I found using Java Object. Cast your b4xView (I'm presuming this as you mention SetColorAndBorder) ... back to a Label , then set the background to a ColorDrawable. Code: Dim LabelBorder As ColorDrawable = lbl.As(Label).Background Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) Upvote 0
Possible solution from snippets I found using Java Object. Cast your b4xView (I'm presuming this as you mention SetColorAndBorder) ... back to a Label , then set the background to a ColorDrawable. Code: Dim LabelBorder As ColorDrawable = lbl.As(Label).Background Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth"))
J Jerryk Active Member Licensed User Longtime User Nov 20, 2024 #3 after startup an error appears B4X: Dim LabelBorder As ColorDrawable = lbl.As(Label).Background Dim jo As JavaObject = LabelBorder >java.lang.RuntimeException: Object should first be initialized (ColorDrawable). Log(jo.GetField("borderWidth")) this edit works B4X: Dim LabelBorder As ColorDrawable LabelBorder.Initialize2(1,2,3,4) Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) > 3 Log(jo.GetField("borderColor")) > 4 adding LabelBorder = lbl.Border after Initialize2 gives the same error How to solve it? Upvote 0
after startup an error appears B4X: Dim LabelBorder As ColorDrawable = lbl.As(Label).Background Dim jo As JavaObject = LabelBorder >java.lang.RuntimeException: Object should first be initialized (ColorDrawable). Log(jo.GetField("borderWidth")) this edit works B4X: Dim LabelBorder As ColorDrawable LabelBorder.Initialize2(1,2,3,4) Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) > 3 Log(jo.GetField("borderColor")) > 4 adding LabelBorder = lbl.Border after Initialize2 gives the same error How to solve it?
J Jerryk Active Member Licensed User Longtime User Nov 20, 2024 #4 I found a solution. Since the code is used inside DesignerCreateView I have to use B4X: Dim LabelBorder As ColorDrawable LabelBorder = mBase.Background Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) Log(jo.GetField("borderColor")) Log(jo.GetField("cornerRadius")) Upvote 0 Solution
I found a solution. Since the code is used inside DesignerCreateView I have to use B4X: Dim LabelBorder As ColorDrawable LabelBorder = mBase.Background Dim jo As JavaObject = LabelBorder Log(jo.GetField("borderWidth")) Log(jo.GetField("borderColor")) Log(jo.GetField("cornerRadius"))