Android Example Round Button - FunWithRoundButtons

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

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Lib files are in the /files folder
     

    Attached Files:

  2. Johan Schoeman

    Johan Schoeman Expert Licensed User

    buttons.png

    This is my first attempt at making use of B4A classes. You will need
    1. JavaObject library
    2. Reflection library
    3. AddPermission("android.permission.VIBRATE") to be added to the manifest - the attached project has this permission already added

    It uses inline Java code to activate the vibrator when a button is pressed

    The buttons all behave differently.
     

    Attached Files:

    Last edited: Jul 8, 2015
    Livio F and koaunglay like this.
  3. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Button animations of the attached project now work properly. Over and above libs mentioned in post #2 above you will also need the StringUtils library.
     

    Attached Files:

  4. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Replace the code in Sub prepCircleButton10 with this:
    Code:
    Sub prepCircleButton10

        cb10.Initialize(b11, p11, 
    34%x70%y10%x10%x)
        cb10.setButtonGradientColor(
    Colors.Green, Colors.Green)
        cb10.setGradientDir = GradDir.RIGHT_LEFT
        cb10.RingColor = 
    Colors.Green
        cb10.Initialize2(Me,
    "cb10_Click")
        cbm10.Initialize(
    File.DirAssets, "youtube48.png")
        cb10.setBitMap = cbm10
    '    cb10.setButtonText = "CLICK ME!"
        cb10.setButtonReaction = Reaction.GROW_ALPHA_SHADOW_AND_SHRINK
        cb10.setRingSize = 
    10
        cb10.setButtonAnimationTime = 
    350
        cb10.setButton
       
    End Sub
    Replace the code of the last CASE in class circleButton with this:

    Code:
    Case "GROW_ALPHA_SHADOW_AND_SHRINK"
            mpleft = mb.Left
            mptop = mb.Top
            mpwidth = mb.Width
            mpheight = mb.Height   
            mp.Color = 
    Bit.AND(sclr(0),Colors.ARGB(80,255,255,255))
            mp.SetLayoutAnimated(animtime, mb.Left-rSize, mb.Top - rSize, mb.Width + (
    2 * rSize), mb.Height + (2 * rSize))
            
    Wait(animtime)
            mp.Invalidate
            mb.Invalidate
            mp.SetLayoutAnimated(animtime, mpleft, mptop, mpwidth, mpheight)
            mp.invalidate
            mb.Invalidate
    This will then make the ring color around the (at present green) YouTube button a reduced alpha color of whatever color you specify with cb10.RingColor = Colors.COLOR
    when the button is pressed/clicked.
     
    Arun Kumar Rajan and DonManfred like this.
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