ai2 app inventor
samsung galaxy note 2
I have a label with Height and Width properties both set in automatic.
Inside an event, for example a button click, I need to to change the
text and the font size of the label and then get the width of it.
Now what happen is that I have to push 2 time the button until will get
the correct value of the label width.
I can suppose this happen because the system can't update the label while inside an event. After several tries, I convinced myself that there is
need of something like DoEvents in Visual Basic.
The file attached "B1.png" show what is not working.
Instead, the code in "B3.png" is working but, for me, useless because
I need to run the code inside an event.
A workaround could be to use a timer and call the function asynchronously.
But I would use this solution only if there is nothing else to do.
Please, provide some suggestion...
So, basically, what I'm trying to do is to put three words,
one at beginning of the x axis less some space, one in the middle
and another one at the end of the x axis less some space.
The first and the last are easy to get but to put the one in the middle
at the exact centre there is need to know how large the text is.
I'm using a phantom label with automatic width(-2) property to get the
text width ((screen.width - text.width) / 2 ).
I can know in advantage the text width of my phone, but, I can't with
the other phones. May change the screen resolution.
I'm trying also to adjust the font size in relation with screen size.
So, I have to put all the code inside a screen.initialize event.
In the next row, with another canvas, I need to show three counters with different font size. I think is too difficulty to get that with screen arrangment and labels. I think the canvas is the best way.
Btw, I've already tried to insert the whole code in a procedure, as you
suggest in the reply, but got the same result of screen.initialize or
one button's solution.
Hope I'm clear
Now my FireFox version is 27.0
Sorry if I'm long