B4A Class Shadow

derez

Expert
Licensed User
Recently I've read few questions about adding shadow to views and decided to make a class for it.
It "just" adds a panel with the required color under the defined view.
Simple methods:
- Initialize(Parent As Panel, V As View, color As Int, angle As Float, margin As Float, radius As Float)
- SetColor(color As Int, radius As Float)
- SetMargin(margin As Float)
- SetAngle(angle As Float)

There is a demo attached.
Comments are welcome !

Edit: Version 2 is here with two more features:
1. When using a bitmap with transparent parts, set -1 as radius (in initialization and in SetColor).
2. Shadow can be rotated but you should rotate it in the same angle you rotate the view...
- SetRotation( Angle As Float)

Edit: Ver. 2.1 - SetRotation rotates the view and the shadow in the defined angle, in degrees

Edit: Ver 2.2 - per Cableguy's request I added option for a gradient shadow. I had to rebuild most of the class, it has an initialization which is just for init, then you have to call start1 or start2. start1 is one color, start2 is gradient. I leave both on for download, if you don't need the gradient - use 2.1
 

Attachments

Last edited:

Cableguy

Expert
Licensed User
Hi Derez,

I have a request: Add an Alpha value to the shadow; I know I can pass it with the shadow color but I would like to achieve a gradiented shadow, going from a solid shadow to a set Alpha value.
 

derez

Expert
Licensed User
Cableguy:
I know I can pass it with the shadow color but I would like to achieve a gradiented shadow, going from a solid shadow to a set Alpha value
I uploaded ver 2.2 which handles gradient, in the gradient colors you can define colors.ARGB so you have the alfa.
Didn't test too much so please check also.
 

zakker

Member
Licensed User
java.lang.RuntimeException: Method: setRotation not found in: anywheresoftware.b4a.BALayout

Why??? :(
 

DonManfred

Expert
Licensed User
Which android jar are you using? In the IDE under Tools-Configure paths?

Make sure to have the newest configured here. 25 is up-to-date
 

DonManfred

Expert
Licensed User
which version of B4A are you using?

Upload a sample project which shows the problem please.

Without source we just can guess, I dont like guessing
 

Erel

Administrator
Staff member
Licensed User
Note that the android.jar is not relevant to this error as this is a run time error. android.jar only affects compile time errors.

View.setRotation was added in Android 3 (API 11). It will not work on older versions of Android.
 

zakker

Member
Licensed User
Note that the android.jar is not relevant to this error as this is a run time error. android.jar only affects compile time errors.

View.setRotation was added in Android 3 (API 11). It will not work on older versions of Android.
Yes Erel, it's my fault !! I was debugging on an old 2.0.3 device... I've tried on a 6.0 and it works fine.

Thank you !!!!
 
Top