Size of canvas can't be changed when screen initializes

I have an app with two labels and a canvas:

The size of the canvas is set to "fill parent" on both the width and the height.

In the blocks section i set the width and height of the canvas to be the same as the screen width and then write these values to the two labels:

Blocks

When I run the app, the size is not being set as I would expect it to: the labels display the size of the canvas without changing the size:

What is the problem here?

Use a clock timer to give the screen a little bit of time to get its own size, before trying to change the canvas size. 250ms is usually enough time.

1 Like

I even tried waiting for the size to change by changing the code this way:
Loop
The loop never finishes.

Try as @TIMAI2 suggested with a clock component

image

See FAQ Section: Waiting and Timing
for why you should not loop like that.

When I was playing with the canvas component, I was experiencing the same thing. The clock component helped, so follow Tim's suggestion.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.