Android Example Round Button - FunWithRoundButtons

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.
 

Attachments

Last edited:

Johan Schoeman

Expert
Licensed User
Replace the code in Sub prepCircleButton10 with this:
B4X:
Sub prepCircleButton10

    cb10.Initialize(b11, p11, 34%x, 70%y, 10%x, 10%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:

B4X:
      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.
 
Top