Android Question Anchor in desinger script

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using the Anchor feature in the designer and it works fine, but I have a problem with it when using the designer script.

Lets say I have a panel with a label and imageview in it, and then Anchor them to the panel, I can then move the panel to adjust the width and the label and imageview moves with it fine.

If I then use the designer script, and make the panel wider such as using the following code in the designer script:

panel1.width = 100%x

The label or imageview doesn't move with it.

Is there a way to make the objects with the Anchor move when you use the designer script ?
 

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am setting the anchors to BOTH.. Unless I am doing it wrong?

Here is how I have it setup:
(Demo project attached)

I have set Label1 to BOTH (Label1 is also a Parent to Panel1):

both.PNG


I then moved Panel1 manually and Label1 moves with it, which is what I want:

drag.PNG



I then want panel1 to be 100% of the width of the screen so I used the designer code to do it.

However, you will notice that Label1 doesn't move when I run the script even knowing when I manually drag Panel1 (not running the script) that Label1 moves like how it should.

script.PNG


Am I using the anchor feature wrong?
 

Attachments

  • designer_demo.zip
    7.2 KB · Views: 113
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Just tried and it seems to fix the problem I had.

Seems that you need to use the anchor with the panel as well and you can't use the script code to re-size the panel. (I guess the anchor is doing the script code for me which saves a lot of time)
 
Upvote 0
Top