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?
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"))
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.
B4X:
Dim LabelBorder As ColorDrawable = lbl.As(Label).Background
Dim jo As JavaObject = LabelBorder
Log(jo.GetField("borderWidth"))
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?
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"))