How can I add a label inside a canvas?

a sample that is easily can be accomplished with canvas + labels + font , but in any other way it will be super hard.

i know i can use sprites instead of labels but the app size will be much big than simple font which doesn't take 400 kb at maximum , instead of more than 20 images which at least it will take 900 kb or 1000 kb.

image

You can also try

1 Like

same problem it crash on the very first run of the app and closes fast

I will check it and see , i tried to import the extension to app inventor and it worked that's promising so far :smiley:

thank you.

A very simple example

1 Like

unfortunately that extension is limited in positions like there are only 9 options so it's not useful for my case.

You can set gravity by giving an integer

image

1 Like

but in his documentation it isn't clear like this so it's more than 9 positions i will try it probably this is the solution for my dilemma , i hope it doesn't crash on start up either :smiley:

i built over 6 apks and didn't work for me can you share your aia file please , for the verticalarrangement i set it fill parent for both height + width but with no work the label is stuck on top left corner even with gravity 300 , 100 and others.

relative_view.aia (6.7 KB)

1 Like

thanks but it's super weird on my emulator

it showed up like this even with gravity 22 , 50 , i'll try it on real device and see.

update : it worked on emulator but probably cache thing of old version of the apk stucked.

@dora_paz

This is what it showed when I tested the AIA. Not sure if this is want @Don_Ammar wanted, though.

1 Like

yes it works fine on real device but on external emulator it doesn't that's really weird

same result as yours on real device i think that is the optimal solution.

update : it worked on emulator but probably cache thing of old version of the apk stucked.

these are the integer values that can be used to change the location

https://developer.android.com/reference/android/view/Gravity.html

is there a way to allocate or position an object via the canvas pixels system like [ X,Y ] ?

i'm still not familiar with that gravity system.

1 Like

is there a way to replace image sprite object with any other ui object or label in order to use these methods ?

image

Not that I am aware of. The imageSprite and Ball are sub components of the canvas. other components such as labels or buttons are in no way actionable via the canvas.

1 Like

Try this version (with the updated extension by @Juan_Antonio):
labelOverCanvas_3.aia (10.9 KB)

1 Like

Awesome Thank you so much @Anke & @Juan_Antonio

It works perfectly without an error + great

now someone can easily accomplish a lot using Canvas

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