B4A Library Floating Action Menu (FAM) and Floating Action Button (FAB)

This is a wrap for this Github Project. Thanx to @ivan.tellez for pointing me into it :)
The library is a replacement for the Floating Action Button lib by @corwin42
They are not compatible as we are both using the same Objectname (FloatingActionbutton).

Requires B4A Version 5.8+

FloatingActionButton
Author:
DonManfred (wrapper)
Version: 1.02
  • FloatingActionButton
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • hasShadow As Boolean
    • hide (animate As Boolean)
      Makes the <b>FloatingActionButton</b> to disappear and sets its visibility to {@link #INVISIBLE}
      animate: if true - plays "hide animation"
    • hideButtonInMenu (animate As Boolean)
      <b>This will clear all AnimationListeners.</b>
    • hideProgress
    • isHidden As Boolean
      Checks whether <b>FloatingActionButton</b> is hidden
      Return type: @return:true if <b>FloatingActionButton</b> is hidden, false otherwise
    • isProgressBackgroundShown As Boolean
    • isProgressIndeterminate As Boolean

      Return type: @return:the mProgressIndeterminate
    • setProgress (progress As Int, animate As Boolean)
    • show (animate As Boolean)
      Makes the <b>FloatingActionButton</b> to appear and sets its visibility to {@link #VISIBLE}
      animate: if true - plays "show animation"
    • showButtonInMenu (animate As Boolean)
    • toggle (animate As Boolean)
    Properties:
    • Background As Drawable
    • ButtonSize As Int
      Sets the size of the <b>FloatingActionButton</b> and invalidates its layout.
    • Color As Int [write only]
    • ColorDisabled As Int
    • ColorNormal As Int
    • ColorPressed As Int
    • ColorRipple As Int
    • Elevation As Float [write only]
    • ElevationCompat As Float [write only]
      Sets the shadow color and radius to mimic the native elevation.

      <p><b>API 21+</b>: Sets the native elevation of this view, in pixels. Updates margins to
      make the view hold its position in layout across different platform versions.</p>
    • Enabled As Boolean
    • Height As Int
    • HideAnimation As Animation [write only]
    • IconDrawable As String [write only]
    • ImageDrawable As Drawable [write only]
    • Indeterminate As Boolean [write only]
      <p>Change the indeterminate mode for the progress bar. In indeterminate
      mode, the progress is ignored and the progress bar shows an infinite
      animation instead.</p>
    • LabelText As String
    • LabelVisibility As Int
    • Left As Int
    • Max As Int
    • Parent As Object [read only]
    • Progress As Int [read only]
    • ProgressBackgroundColor As Int
    • ProgressColor As Int
    • ProgressWidth As Int
    • ShadowColor As Int
    • ShadowRadius As Int
      Sets the shadow radius of the <b>FloatingActionButton</b> and invalidates its layout.
      <p>
      Must be specified in density-independent (dp) pixels, which are then converted into actual
      pixels (px).
    • ShadowXOffset As Int
      Sets the shadow x offset of the <b>FloatingActionButton</b> and invalidates its layout.
      <p>
      Must be specified in density-independent (dp) pixels, which are then converted into actual
      pixels (px).
    • ShadowYOffset As Int
      Sets the shadow y offset of the <b>FloatingActionButton</b> and invalidates its layout.
      <p>
      Must be specified in density-independent (dp) pixels, which are then converted into actual
      pixels (px).
    • ShowAnimation As Animation [write only]
    • ShowProgressBackground As Boolean [write only]
    • ShowShadow As Boolean [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • FloatingActionMenu
    Events:
    • onClick (obj As View)
    • onMenuToggle (opened As Boolean)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • addMenuButton (fab As FloatingActionButton)
    • addMenuButton2 (fab As FloatingActionButton, index As Int)
    • close (animate As Boolean)
    • hideMenu (animate As Boolean)
      Makes the {@link #FloatingActionMenu} to disappear and sets its visibility to {@link #INVISIBLE}
      animate: if true - plays "hide animation"
    • hideMenuButton (animate As Boolean)
      Makes the {@link FloatingActionButton} to disappear inside the {@link #FloatingActionMenu} and
      sets its visibility to {@link #INVISIBLE}
      animate: if true - plays "hide animation"
    • isAnimated As Boolean
    • isIconAnimated As Boolean
    • isMenuButtonHidden As Boolean
    • isMenuHidden As Boolean
    • isOpened As Boolean
    • open (animate As Boolean)
    • removeAllMenuButtons
    • removeMenuButton (fab As FloatingActionButton)
    • showMenu (animate As Boolean)
      Makes the whole {@link #FloatingActionMenu} to appear and sets its visibility to {@link #VISIBLE}
      animate: if true - plays "show animation"
    • showMenuButton (animate As Boolean)
      Makes the {@link FloatingActionButton} to appear inside the {@link #FloatingActionMenu} and
      sets its visibility to {@link #VISIBLE}
      animate: if true - plays "show animation"
    • toggle (animate As Boolean)
    • toggleMenu (animate As Boolean)
    • toggleMenuButton (animate As Boolean)
    Properties:
    • ActivityHeight As Int [write only]
    • ActivityWidth As Int [write only]
    • Animated As Boolean [write only]
      Sets whether open and close actions should be animated
    • AnimationDelayPerItem As Int
    • Background As Drawable
    • ClosedOnTouchOutside As Boolean [write only]
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • IconAnimated As Boolean [write only]
    • IconAnimationCloseInterpolator As Interpolator [write only]
    • IconAnimationInterpolator As Interpolator [write only]
      Sets the {@link android.view.animation.Interpolator} for <b>FloatingActionButton's</b> icon animation.
    • IconAnimationOpenInterpolator As Interpolator [write only]
    • IconToggleAnimatorSet As AnimatorSet
    • LabelsCornerRadius As Int
    • LabelsMargin As Int
    • LabelsMaxLines As Int
    • LabelsPaddingBottom As Int
    • LabelsPaddingLeft As Int
    • LabelsPaddingRight As Int
    • LabelsPaddingTop As Int
    • LabelsPosition As Int
    • Left As Int
    • MenuButtonColorNormal As Int
    • MenuButtonColorPressed As Int
    • MenuButtonColorRipple As Int
    • MenuButtonHideAnimation As Animation [write only]
    • MenuButtonLabelText As String
    • MenuButtonShowAnimation As Animation [write only]
    • MenuIconView As ImageView [read only]
    • OpenDirection As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

Known problems:
- I still don´t know what the problem is, but the first 2 FABs (FloatingActionButton) added to the FAM (FloatingActionMenu)will be ignored; they do not show in menu
But away from this it works fine here

Screenshot_20160325-080229.png


If you want to donate for my work building the wrapper you can do it here:
 

Attachments

  • FAMFABEx.zip
    18.3 KB · Views: 1,895
  • FloatingActionButtonV1.0.2.zip
    57 KB · Views: 1,941
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
May I ask a very stupid question.

What do you mean by API Level: 14. Android 4.0 ( ICE_CREAM_SANDWICH ) is required to use this lib ?

Does it mean the the android.jar version (ie in the B4A IDE, Tools->Configure Paths, android.jar)

OR

The devices that use this lib (final apk) should have Android version 14 or above running on it

Excuse me if this question is out of topic as far as this thread is concerned.

Regards
Anser
 

Tayfur

Well-Known Member
Licensed User
Longtime User
ı added it .
now recive ...

java.lang.NoSuchMethodError: No static method getColor(Landroid/content/Context;I)I in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/contact.backup-2/base.apk)
 

stanks

Active Member
Licensed User
Longtime User
maybe it is stupid question but, why

B4X:
...
    fam.ActivityHeight = 100%y
    fam.ActivityWidth = 100%x
...

thanks
 
Last edited:

aldifong

Member
Licensed User
Longtime User
Hi all,


I try the fab sample and it's running well. But when i try to create a new sample project to implement the fab, it failed.

I put the fab on the layout design and then on the activity_create, i just initialize the layout. But it failed...
So strange, in project libraries, i have core v5.8 and floating action button v1.02.


What might gone wrong? I'm not event start to code on the activity yet.


Thanks to any reply...
 

anOparator

Active Member
Licensed User
Longtime User
Hello and thank you for this great Lib ,, but im having difficulties setting the fam on the right side of the activity even in the example if you just rotate the phone it gets in the middle of the activity ,,, im trying to set it manually not with the designer

B4X:
fam.Initialize("fam")
Activity.AddView(fam,0,0,100%x,100%y)
fam.ActivityHeight =100%y
fam.ActivityWidth = 100%x

i tried to play with left setting ...

B4X:
fam.left = 100dip

is just not working it takes the whole fam 100dip from the left also i tried to give the fam 100dip width and the left as 100%x - 100dip but still no luck .... any ideas ?
B4X:
Sub Activity_Create
...
fam.Activity Width = 100%x
If Activity.Width < Activity.Height Then
fam.SetLayout (250dip, 30dip, 50dip, 50dip)
Else
fam.SetLayout (550dip, 30dip, 50dip, 50dip)
End If 
...
...
play with the numbers , and btn1.LabelText can have any size content.
oops, btn1.LabelText disappear.

edit: The third arg of fam.SetLayout is the width of btn1.LabelText, 280dip works well for me.
 
Last edited:

itgirl

Active Member
Licensed User
Longtime User
B4X:
Sub Activity_Create
...
fam.Activity Width = 100%x
If Activity.Width < Activity.Height Then
fam.SetLayout (250dip, 30dip, 50dip, 50dip)
Else
fam.SetLayout (550dip, 30dip, 50dip, 50dip)
End If
...
...
play with the numbers , and btn1.LabelText can have any size content.
oops, btn1.LabelText disappear.

edit: The third arg of fam.SetLayout is the width of btn1.LabelText, 280dip works well for me.
thank you for pointing me to the right direction
i have tried
fam.SetLayout (100%x - 75dip, 30dip, 50dip, 50dip)

the left side works great but the btn1.LabelText is gone too i tried 280dip but sadly didnt work i think i will try other widths
 

Daniel-White

Active Member
Licensed User
Longtime User
I did not discover how to show the buttons horizontals instead vertical. Can we do that? the example show the buttons vertically. I would like to put horizontal.
Thankssssssssssssssssssss
 

johndb

Active Member
Licensed User
Longtime User
i know lol but still not a very good approach because as of some RTL languages it seems to be a problem

do you think the layout has anything to do with it ?

B4X:
<com.github.clans.fab.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        android:src="@drawable/ic_menu"
        fab:fab_colorNormal="@color/app_primary"
        fab:fab_colorPressed="@color/app_primary_pressed"
        fab:fab_colorRipple="@color/app_ripple"/>

as you can see in the main project the gravity is set to bottom|right
Has there been any further investigation & update on why we can't align the menu at a specific location?
 

DonManfred

Expert
Licensed User
Longtime User

achtrade

Active Member
Licensed User
Longtime User
The demo app works fine, my app only shows the buttons, the labels are missing. I'm using the exact same code. any idea ?
 

m643

Member
Licensed User
Longtime User
Can you help me with this? I wanna use the floating action menu in custom listview but the when I click the button the rest of the buttons are opened inside of the panel (see screenshot) How can I fix this?

upload_2016-12-10_20-2-41.png
 

Haris Hafeez

Active Member
Licensed User
Longtime User
I may be missing something obvious here but can we change the menu button's icon? In the example it seems to be fixed to show the '+' sign on the menu button.
 
Top