Android Example ImageView - Circular, Hexagonal, Triangular, Bubble, Star Imageviews (with inline Java code)

Discussion in 'Tutorials & Examples' started by Johan Schoeman, Mar 9, 2015.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Parrots.png See attached project with inline Java code to create round imageviews. You only need library JavaObject V2.01 to be enabled.
     

    Attached Files:

    Last edited: Jul 7, 2015
    JesusGB, HAH, Jones Hone and 22 others like this.
  2. Jaames

    Jaames Active Member Licensed User

    Thanks for sharing
     
    Johan Schoeman likes this.
  3. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

  4. Johan Schoeman

    Johan Schoeman Expert Licensed User

    HexagonImageView.png

    The attached project adds the ability to display bitmap images in a hexagonal ImageView
     

    Attached Files:

    Last edited: Jul 7, 2015
    lemonisdead likes this.
  5. Johan Schoeman

    Johan Schoeman Expert Licensed User

    TriangleBitmap.png

    The attached project adds the ability to display bitmap images in a triangular ImageView
     

    Attached Files:

    Last edited: Jul 7, 2015
    lemonisdead, Mahares and DonManfred like this.
  6. Mahares

    Mahares Well Known Member Licensed User

    @Johan Schoeman: Excellent example. I added some silly code to your project:
    Code:
    Sub ImageView1_Click
        
    Msgbox("I am a parrot trapped in a Triangle.","")
    End Sub
    Sub ImageView2_Click
        
    Msgbox("I am a parrot trapped in a Hexagon.","")
    End Sub
    Sub ImageView3_Click
        
    Msgbox("I am a parrot trapped in a Circle.","")
    End Sub
    Vive l' Afrique
     
    Johan Schoeman likes this.
  7. Johan Schoeman

    Johan Schoeman Expert Licensed User

    BubbleBitmap.png BubbleBitmap_alone.png ...and last but not least, adding the ability to display bitmap images in a "bubble/droplet" ImageView. From here on you can add more methods to create various/different shapes of imageviews by drawing the required path. Perhaps a bit of maths and trigonometry will be required to do some special shapes - but should be relatively easy to do so.
    Take note of the line in method
    public static Bitmap getBubbleBitmap(Bitmap scaleBitmapImage) {
    ...
    ....
    path.addArc(oval, 0, 270); //in degrees!

    Here 0 degrees is measured from to the right most point of the x-axis and 270 is the top most point of the y-axis. The arc is drawn CLOCKWISE form the starting point (0 degrees) to the end point (270 degrees).
     

    Attached Files:

    Last edited: Jul 7, 2015
    lemonisdead likes this.
  8. Johan Schoeman

    Johan Schoeman Expert Licensed User

    StarBitmap.png

    Added the ability to display the bitmap within the Imageview as a star. Use the spinner to select the number of "points" that the star should have (spinner ranges from 4 to 50). Also added a cone shape:
    bm2 = nativeMe.RunMethod("getConeBitmap",Array(bm))
     

    Attached Files:

    Last edited: Jul 7, 2015
    lemonisdead and DonManfred like this.
  9. Johan Schoeman

    Johan Schoeman Expert Licensed User

    HeartBitmap.png

    Displaying the bitmap within the Imageview as a heart and also a star with a circle around it...just for fun.
     

    Attached Files:

    Last edited: Jul 7, 2015
    lemonisdead and DonManfred like this.
  10. achtrade

    achtrade Active Member Licensed User

    I'm getting this error: Unknown member: InitializeContext

    in this instruction :

    nativeMe.InitializeContext
     
  11. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Do you have library JavaObject V2.01 installed and enabled?
     
  12. achtrade

    achtrade Active Member Licensed User

    mine says 1.20, where can I get the 2.01 ?
     
  13. klaus

    klaus Expert Licensed User

    JavaObjects is deliverd with B4A.
    What version of B4A are you using ?
     
  14. achtrade

    achtrade Active Member Licensed User

    b4a 4.30
     
  15. klaus

    klaus Expert Licensed User

    Do you have JavaObject files in the AdditionalLibraries folder ?
    Check if you have the JavaObject are in the Library folder of B4A.
    Then remove the JavaObject files in the AdditionalLibraries folder.
     
  16. achtrade

    achtrade Active Member Licensed User

    JavaObject files are in Libraries, date 4/30/2014, I don't have AddiontalLibraries
     
  17. klaus

    klaus Expert Licensed User

    Strange.
    The date of my files is 2015.02.03.
    Where do you save additional libraries not shipped with B4A ?
     
  18. achtrade

    achtrade Active Member Licensed User

    I put everything in the Libraries folder. is that wrong ?
     
  19. klaus

    klaus Expert Licensed User

    Yes.
    Look at chapter 14.7.2 Additional libraries folder in the Beginner's Guide.
     
  20. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Here is the JavaObject V2.01 files. Try them and see what happens
     

    Attached Files:

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