B4A Class Shadow

Discussion in 'Additional libraries, classes and official updates' started by derez, Dec 7, 2014.

  1. derez

    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
     

    Attached Files:

    Last edited: Sep 5, 2015
  2. derez

    derez Expert Licensed User

    Version 2 , see first post.
     
    majidhassani likes this.
  3. derez

    derez Expert Licensed User

    Attached a demo of a clock with shadows.
    Edit: updated the demo with a button to show real time and display a digital time for those who never learned how to read an analog clock...
     

    Attached Files:

    Last edited: Dec 8, 2014
    majidhassani and ellpopeb4a like this.
  4. derez

    derez Expert Licensed User

    This one is a beauty !
     

    Attached Files:

    Last edited: Dec 8, 2014
    majidhassani, shashkiranr and Erel like this.
  5. derez

    derez Expert Licensed User

    Ver. 2.1 - SetRotation rotates the view and the shadow in the defined angle, in degrees
     
    majidhassani likes this.
  6. MhdBoy

    MhdBoy Member Licensed User

    Very useful
    tnx a lot
     
  7. Peter Simpson

    Peter Simpson Expert Licensed User

    Hmm interesting...
     
  8. Rob Rendle

    Rob Rendle Member Licensed User

    Perfect. Thank you
     
  9. Cableguy

    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.
     
  10. derez

    derez Expert Licensed User

    Cableguy:
    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.
     
  11. zakker

    zakker Member Licensed User

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

    Why??? :(
     
  12. DonManfred

    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
     
  13. zakker

    zakker Member Licensed User

    this is mine : C:\Android\android-sdk\platforms\android-25\android.jar
     
  14. DonManfred

    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
     
  15. zakker

    zakker Member Licensed User

    6.50 and JavaObject Library 2.05
     
  16. Erel

    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.
     
  17. zakker

    zakker Member Licensed User

    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 !!!!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice