how to drawtext in the middle of canvas

815 views
Skip to first unread message

張家倫

unread,
Jul 20, 2016, 2:58:49 AM7/20/16
to MIT App Inventor Forum
hello everyone~~
I have a problem...
I want to drawtext in the middle of the canvas((just like the topic...
but I have some question...
let me explain:
how can let TextAlignment work??@@
because the block drawtext have to give it the X and Y...
it makes the text didn't draw in the middle...
I have surfed so many information...
but nothing can help me to fix it
I need somebody help me...

and my English is poor...
please forgive me
I will thank you a lot~~>< 

Ghica

unread,
Jul 20, 2016, 5:24:37 AM7/20/16
to MIT App Inventor Forum
In the designer you can set the text alignment to left, right or center (center is the default I think). This means that the text will be drawn centered to the x,y point you specify. You must also take care of the fontsize, and adjust y accordingly, otherwise the text my be higher that you think. Experiment!!
Cheers, Ghica.

ScottFerguson

unread,
Jul 20, 2016, 7:06:36 AM7/20/16
to MIT App Inventor Forum
As Ghica says.
Use center alignment and canvas.Width/2 for the drawtext x value.
And when positioning in the y direction set the drawtext y value to canvas.Height/2 + canvas.FontSize/2  

Abraham Getzler

unread,
Jul 20, 2016, 12:38:19 PM7/20/16
to MIT App Inventor Forum
Good to know! I was wondering what that attribute meant.
Sample app published here ...
and in attachments .
ABG

blocks.png
Samaritan.aia
2016-07-20 12_31_29-5554__build_.png

張家倫

unread,
Jul 21, 2016, 12:51:32 AM7/21/16
to MIT App Inventor Forum
so...the textalignment can't work...
we always have to give the x and y
and the textalignment just for looking...
or it just a decoration, is it??@@
whether we set the textalignment or not we still have to let the text in the middle by x and y??

Italo

unread,
Jul 21, 2016, 1:11:04 AM7/21/16
to MIT App Inventor Forum
I think you don't understand how alignment works. It doesn't mean that the text will be aligned relative to the screen. It's relative to the X,Y provided in your DrawText block.
And of course you always have to give the X,Y. If not, how is the app supposed to know where you want your text placed?
This is how the alignment options are used in App Inventor 2.



Ghica

unread,
Jul 21, 2016, 3:11:55 AM7/21/16
to MIT App Inventor Forum
Wow. If that is not clear...
These are chocolate letters! (We eat them in december).
Cheers, Ghica.

張家倫

unread,
Jul 21, 2016, 5:07:37 AM7/21/16
to MIT App Inventor Forum
OK~~I got it~~
thank for everyone~~QAQ
I know I am not a smart student...
To be my teacher(I mean all of you) is a very difficult test....@@
so thank for everyone~~I really appreciate~~>0<

Ghica

unread,
Jul 21, 2016, 5:49:31 AM7/21/16
to MIT App Inventor Forum
Now, can you tell me what QAQ means?
In my language this sounds as something ducks say.
Cheers, Ghica.

張家倫

unread,
Jul 21, 2016, 7:16:38 AM7/21/16
to MIT App Inventor Forum
oh~~this is a face
it mean cry~~
QAQ the O is eyes
and \ is tears
the A is mouth
so QAQ is a crying face
sometimes you can use it to express you are be touched
or you are really appreciate~~
if I cry because of feeling sad
I will type TAT
It is real sad
so it is for me not the formal use((I think...

Ghica

unread,
Jul 21, 2016, 8:02:30 AM7/21/16
to MIT App Inventor Forum
I understand. Be happy!

張家倫

unread,
Jul 21, 2016, 9:12:13 AM7/21/16
to MIT App Inventor Forum
you too~~thank for everything you help~~^^
Reply all
Reply to author
Forward
0 new messages