Button or canvas shadow

246 views
Skip to first unread message

Vratislav

unread,
May 8, 2017, 3:03:07 AM5/8/17
to MIT App Inventor Forum
Hi, is there any possibility to add a shadow (defined one with more parameters) to buttons or canvas? I mean the shadow around the blocks. I can't find any manual how to do it.

SteveJG

unread,
May 8, 2017, 8:21:56 AM5/8/17
to MIT App Inventor Forum
Buttons and the Canvas do not have any property that allows a shadow with App Inventor.

You can simulate this effect by creating your own button image...a png image perhaps that has a 'shadow' created using an image manipulation program like GIMP 2.
You can do something with an image like this for your 'button' https://docs.gimp.org/en/script-fu-drop-shadow.html     This will work best if your image is the same dimensions and 
aspect ratio as your button. Place the image in Button.Image

Try it and let us know how it works for you.

Similarly, you could use an image for the Canvas background perhaps.  Use Canvas.BackgroundImage.

Regards,
Steve

SteveJG

unread,
May 8, 2017, 10:43:00 AM5/8/17
to mitappinv...@googlegroups.com
...a simple example

                                                                                             Designer view                emulator view


if you have superior graphic skills, you will get a better result.  The example button image is 109x80 .. not ideal but the png image can be scaled using an image manipulation program on your PC.  You can trim it as you like.  This was done with GIMP 2.  Experiment with the button shape...this is rectangular, rounded perhaps provides a better effect.

Regards,
Steve


shadowButton2.png

Vratislav

unread,
May 12, 2017, 4:18:46 AM5/12/17
to MIT App Inventor Forum
Thanks. Button shadows made in graph. design tools are no problem. I was asking about any function for item shadow in App Inv. because I have a special requests. I need to use a slider and the shadow size of another items will increase or decrease by changing values of the slider. Do you have any idea? Is a good way to prepare a set of button or canvas backgrounds with different shadows and change the images when using slider?

SteveJG

unread,
May 12, 2017, 8:00:56 AM5/12/17
to mitappinv...@googlegroups.com
Sorry, no idea at all.  App Inventor's graphics capabilities are very rudimentary compared to the professional compilers.  Is what you want to do possible with Android Studio or one of the professional compilers?  What you want to do (create a function to produce a shadow in multiple situations)  is a very specialized activity. I doubt it will ever be possible with App Inventor.  Using an image with a 'built-in" shadow might be the best that is possible.

Abraham Getzler

unread,
May 12, 2017, 12:46:40 PM5/12/17
to MIT App Inventor Forum
If all this is happening on a canvas,
consider matching each button sprite with a matching dark shadow
sprite under it (z1 < z2) and displaced diagonally by depth.

ABG

Reply all
Reply to author
Forward
0 new messages