Android Question Custom control strange behaviour

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi everyone

I creted custom control and there is a strange behavior that I can not solve.

I created this properties:

B4X:
#DesignerProperty: Key: ShowEditor,                 DisplayName: Show Editor, FieldType: Boolean, DefaultValue: true
#DesignerProperty: Key: Multilinee,                 DisplayName: Multi Line,                 FieldType: Boolean, DefaultValue: true
#DesignerProperty: Key: FieldDescription,     DisplayName: Edit Description,     FieldType: String,     DefaultValue:

Immagine.png


and when setting the ShowEditor or MultiLine at true, the control not mantein the width.

I checked the width with the log ed value is -1

I not use the

B4X:
mCtrlNostroRiferimento.Width    =    pnlDatiTesta.Width

the controls work?! but widht is'nt correct


can tell me why?
thank in advance
 

stevel05

Expert
Licensed User
Longtime User
You should use Anchors instead of the script. The script is useful for more complex management, but for simply setting widths and height's to 100% Anchors are simpler.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You need to stretch them the full width of the layout in the designer.

The designed layout needs to fit the variant you are using, then the scaling and designer scripts will work as expected.

If you copy to a new variant, you need to set it correctly to fit. But if you do it correctly in the first place, there is rarely a need for multiple variants.
 
Last edited:
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
i would rather not create meny variants of the same layout! I not understand because the script work in this mode?!

I've already seen the tutorial
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The script will work if the layout is setup correctly, but Anchors are easier.

Can you post the layout?
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
I repeat, the problem is that the layout does not behave correctly if I use the custom parameters.

the layout is part of a very large project that I can not share. I will try to do a smaller project.
thank you
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It would also be useful to have some additional info. Like what selecting the custom parameters actually does in the code?
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
I'v see a strangeness in the map of properities

- there are 3 properties

B4X:
#DesignerProperty: Key: ShowEditor,                 DisplayName: Show Editor, FieldType: Boolean, DefaultValue: true
#DesignerProperty: Key: Multilinee,                 DisplayName: Multi Line,                 FieldType: Boolean, DefaultValue: true
#DesignerProperty: Key: FieldDescription,     DisplayName: Edit Description,     FieldType: String,     DefaultValue:


but in map object shows more properties that I removed. See after:


key defaultcolor value -984833
key activity value anywheresoftware.b4a.BALayout{ad24022 V.E..... ......ID 0,0-1280,775 #1}
key ba value anywheresoftware.b4a.BA@275bdab3
key eventName value mctrlvostroriferimento
key customType value dev.meta.sb.cctrledit
key shortType value CCtrlEdit
key Multilinee value true
key FieldDescription value Vostro Riferimento
key ShowEditor value true
key csType value Dbasic.Designer.MetaCustomView+CustomDataGrid
key ShowEdit value false
key VisualizzaEditor value true
key type valore

Why?

thank
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You probably need to load and save the layout to get rid of them.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
done many times. I've open the file and there is the information, but I can not cancel. Even if I do not know if this is the cause of the problem
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Try removing the customview from the layout and adding a new one.
 
Upvote 0
Top