B4A Library [B4X] [XUI] AS Tab Menu (Bottom Menu/Navigation)

Hey B4X-Forum! New Year, new views! :)
The first one from me for this year is a better, simpler, faster and scalable Tab/Bottom-Menu.

i spend a lot of time in creating views, some views i need by my self, but some views not and to create a high quality view cost a lot of time. If you want to support me, then you can do it here by Paypal. :)
B4j: jXUI,jBitmapCreator
B4a: XUi,Reflection
B4i: iXUI
Features
  • cross-platform compatible
  • use it Horizontal or Vertical
  • reponsive design
  • 1 Underline Animations
  • easy to use
  • you can use 2,3,4,5,6,7,8,9,10, > endless tabs
  • only Text, only icons or text with icons
  • show badges
You need 8 Tabs? no problem! Create as many tabs as fit on the screen, perfect for tablets too.
Screenshot_20200224-203427__01.jpg

Resize it
AS Tab Menu Demo low.gif

Text with Icon
Screenshot_20200224-203427.jpg
Only Text
Screenshot_20200224-203500.jpg
Only Icon
Screenshot_20200224-203443.jpg
Change it on the fly
ezgif.com-resize.gif
AS Tab Menu Demo 2.gif

Show Parting Lines
Screenshot_20200226-093218.jpg

Use it vertical
Screenshot_20200302-121054.jpgScreenshot_20200302-120951.jpg
Show badges
Screenshot_20200325-162119.jpgScreenshot_20200325-161959.jpgScreenshot_20200325-162212.jpg
You need to scroll? No problem look at this example.
AS Tab Menu with xCustomListView.gif

Examples
Add 8 Tabs Example (Text with Icon):
    ASTabMenu1.AddTab(xui.Color_ARGB(255,39, 174, 97),"Test",ASTabMenu1.FontToBitmap(Chr(0xF015),False,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(152,39, 174, 97),"Test1",ASTabMenu1.FontToBitmap(Chr(0xF179),False,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(255,39, 174, 97),"Test3",ASTabMenu1.FontToBitmap(Chr(0xF11B),False,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(152,39, 174, 97),"Test4",ASTabMenu1.FontToBitmap(Chr(0xE859),True,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(255,39, 174, 97),"Test5",ASTabMenu1.FontToBitmap(Chr(0xF011),False,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(152,39, 174, 97),"Test6",ASTabMenu1.FontToBitmap(Chr(0xF1E2),False,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(255,39, 174, 97),"Test7",ASTabMenu1.FontToBitmap(Chr(0xF1EB),False,30,xui.Color_White),"")
    ASTabMenu1.AddTab(xui.Color_ARGB(152,39, 174, 97),"Test8",ASTabMenu1.FontToBitmap(Chr(0xF239),False,30,xui.Color_White),"")
Add a Tab without an icon, just with text:
ASTabMenu1.AddTab(xui.Color_ARGB(255,39, 174, 97),"Test",Null,"")
Change text font:
ASTabMenu.text_font = xui.CreateDefaultBoldFont(15)
ASTabMenu.CommitChanges
ASTabMenu
Author: Alexander Stolte
Version: 1.23

  • ASTabMenu
    • Events:
      • TabClick (index As Int)
    • Fields:
      • text_font As B4XFont
      • TextIcon_Padding As Float
    • Functions:
      • AddTab (background_color As Int, text As String, icon As B4XBitmap, tag As Object) As String
        adds a new tab
      • Badge_getColor (index As Int) As Int
      • Badge_getHeight As Float
      • Badge_getLabel (index As Int) As B4XView
        gets the badge label, to modify it to your own
      • Badge_getVisible (index As Int) As Boolean
      • Badge_setColor (index As Int, color As Int) As String
        gets or sets the badge color
      • Badge_setHeight (size As Float) As String
        gets or sets the badge height, per default it is 15dip
      • Badge_setText (index As Int, number As Int) As String
        sets the badge number, set it to -1 to have only the color
      • Badge_setVisible (index As Int, visible As Boolean) As String
        show or hide the badge on a tab
      • Badge_setVisibleEasy (index As Int, number As Int, color As Int) As String
        shows the badge with all important settings to save lines of code
      • Class_Globals As String
      • CommitChanges As String
        Refresh the view and commit changes to the view
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • FontToBitmap (text As String, IsMaterialIcons As Boolean, FontSize As Float, color As Int) As B4XBitmap
      • getBadge_Gravity As String
      • getBadge_MIDDLELEFT As String
      • getBadge_MIDDLERIGHT As String
      • getBadge_TOPLEFT As String
      • getBadge_TOPMIDDLE As String
      • getBadge_TOPRIGHT As String
      • getBaseView As B4XView
        gets the mbase
      • getCommitMode As String
      • getCommitMode_AUTOMATIC As String
      • getCommitMode_MANUALLY As String
      • getCurrentIndex As Int
        gets the current tab index
      • getCurrentTabUnderline As Boolean
        hide or shows the underline
      • getCurrentTabUnderlineAnimation As String
        gets or sets the underline animation
      • getCurrentTabUnderlineAnimation_NORMAL As String
      • getCurrentTabUnderlineAnimationDuration As Int
        gets or sets the duration of the underline animation
      • getCurrentTabUnderlineGravity As String
        gets or sets the gravity of the underline
      • getCurrentTabUnderlineGravity_BOTTOMRIGHT As String
      • getCurrentTabUnderlineGravity_TOPLEFT As String
      • getEnableSelectedTabTextColor As Boolean
        enable or disable the tab text color on clicking on a tab
      • getHaloDuration As Int
      • getOrientation_AUTOMATIC As String
      • getOrientation_HORIZONTAL As String
      • getOrientation_VERTICAL As String
      • getPartingLineColor As Int
        gets or sets the color of the parting line
      • getPartingLineVisible As Boolean
        show or hide the parting line
      • getPartingLineWidth As Float
        gets or sets the thickness of the parting line
      • getSelectedTabTextColor As Int
        gets or sets the text color of the selected tab
      • getTabBackgroundColor (index As Int) As Int
      • getTabClickColor As Int
        gets or sets the tab click color
      • getTabIcon (index As Int) As B4XBitmap
        gets or sets the icon of a tab
      • getTabSize As Int
        Gets the Number of Tabs
      • getTabStripMode As Boolean
        sets or gets the TabStripMode, if true the underline width is the full tab
      • getTabStyle As String
        gets or sets the tab style
      • getTabStyle_ICON As String
      • getTabStyle_TEXT As String
      • getTabStyle_TEXTICON As String
      • getTabTag (index As Int) As Object
        gets or sets the tag of a tab
      • getTabText (index As Int) As String
        gets or sets the text of a tab
      • getTabTextColor As Int
      • getUnderLineColor As Int
        gets or sets the color of the underline
      • getUnderLineHeight As Float
        gets or sets the thickness of the underline
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • RemoveAllTabs As String
      • RemoveAt (index As Int) As String
        Removes the tab on the given index, if the current index is higher then the number of views, then the current index is set to 0 and the first tab is clicked
      • setBadge_Gravity (badge_gravity As String) As String
        for example take this enum for parameter: Badge_MIDDLERIGHT
        Has no effect with only Text
      • setBadge_setLeftPadding (padding As Float) As String
      • setCommitMode (commit_mode As String) As String
      • setCurrentTabUnderline (show As Boolean) As String
      • setCurrentTabUnderlineAnimation (animation As String) As String
      • setCurrentTabUnderlineAnimationDuration (duration As Int) As String
      • setCurrentTabUnderlineGravity (underline_gravity As String) As String
      • setEnableSelectedTabTextColor (enable As Boolean) As String
      • setHaloDuration (duration As Int) As String
      • setPartingLineColor (clr As Int) As String
      • setPartingLineVisible (visible As Boolean) As String
      • setPartingLineWidth (width As Float) As String
      • setSelectedTabTextColor (color As Int) As String
      • SetTab (index As Int, withClickEvent As Boolean, withHalo As Boolean) As String
        sets the selected tab
      • setTabBackgroundColor (index As Int, colour As Int) As String
        sets or gets the background color of a tab
      • setTabClickColor (color As Int) As String
      • setTabIcon (index As Int, icon As B4XBitmap) As String
      • setTabStripMode (enable As Boolean) As String
      • setTabStyle (style As String) As String
      • setTabTag (index As Int, tag As Object) As String
      • setTabText (index As Int, text As String) As String
      • setTabTextColor (color As Int) As String
        gets or sets the non selected tab text color
      • setUnderLineColor (clr As Int) As String
      • setUnderLineHeight (height As Float) As String
      • ViewEnable (enable As Boolean) As String
      • VisibleAt (index As Int, visible As Boolean) As String
    • Properties:
      • Badge_Gravity As String
        for example take this enum for parameter: Badge_MIDDLERIGHT
        Has no effect with only Text
      • Badge_MIDDLELEFT As String [read only]
      • Badge_MIDDLERIGHT As String [read only]
      • Badge_setLeftPadding
      • Badge_TOPLEFT As String [read only]
      • Badge_TOPMIDDLE As String [read only]
      • Badge_TOPRIGHT As String [read only]
      • BaseView As B4XView [read only]
        gets the mbase
      • CommitMode As String
      • CommitMode_AUTOMATIC As String [read only]
      • CommitMode_MANUALLY As String [read only]
      • CurrentIndex As Int [read only]
        gets the current tab index
      • CurrentTabUnderline As Boolean
        hide or shows the underline
      • CurrentTabUnderlineAnimation As String
        gets or sets the underline animation
      • CurrentTabUnderlineAnimation_NORMAL As String [read only]
      • CurrentTabUnderlineAnimationDuration As Int
        gets or sets the duration of the underline animation
      • CurrentTabUnderlineGravity As String
        gets or sets the gravity of the underline
      • CurrentTabUnderlineGravity_BOTTOMRIGHT As String [read only]
      • CurrentTabUnderlineGravity_TOPLEFT As String [read only]
      • EnableSelectedTabTextColor As Boolean
        enable or disable the tab text color on clicking on a tab
      • HaloDuration As Int
      • Orientation_AUTOMATIC As String [read only]
      • Orientation_HORIZONTAL As String [read only]
      • Orientation_VERTICAL As String [read only]
      • PartingLineColor As Int
        gets or sets the color of the parting line
      • PartingLineVisible As Boolean
        show or hide the parting line
      • PartingLineWidth As Float
        gets or sets the thickness of the parting line
      • SelectedTabTextColor As Int
        gets or sets the text color of the selected tab
      • TabClickColor As Int
        gets or sets the tab click color
      • TabSize As Int [read only]
        Gets the Number of Tabs
      • TabStripMode As Boolean
        sets or gets the TabStripMode, if true the underline width is the full tab
      • TabStyle As String
        gets or sets the tab style
      • TabStyle_ICON As String [read only]
      • TabStyle_TEXT As String [read only]
      • TabStyle_TEXTICON As String [read only]
      • TabTextColor As Int
        gets or sets the non selected tab text color
      • UnderLineColor As Int
        gets or sets the color of the underline
      • UnderLineHeight As Float
        gets or sets the thickness of the underline
  • Tabs
    • Fields:
      • badge_visible As Boolean
      • Icon As B4XBitmap
      • Index As Int
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • TabText As String
      • Tag As Object
      • Visible As Boolean
    • Functions:
      • Initialize
        Initializes the fields to their default value.
ToDo's
  • BitmapCreator Effects
  • Add Stretch underline animation
  • Underline Option: Circle, instead of a line, a circle/dot
Ideas
  • Animation: Only Icon, if you click on it, then the text from the Tab appears
Changelog
  • 1.0
    • Release
  • 1.01
    • Add RemoveAt - Removes a tab by a given index
      • RemoveAt in action.gif
    • Add Property PartingLineVisible - shows an parting line between the tabs
      • Screenshot_20200226-093218.jpg
      • Add get and set PartingLineColor
      • Add get and set PartingLineWidth
      • Add get and set PartingLineVisible
    • Add get and set UnderLineColor
    • Add get and set UnderLineHeight
    • Add getTabIcon -gets the icon of a given tab
    • Add setTabIcon -sets a new icon to a tab
    • Add getTabText -gets the text ov a given tab
    • Add setTabText -sets a new text to a tab
  • 1.02
    • Add getTabTag
    • Add setTabTag
  • 1.03
    • Add Property Orientation - indicates the mode in which the view is, horizontal or vertical
    • The menu can now be used vertical
    • Add Property CurrentTabUnderlineGravity - sets the underline gravity, on vertical mode = Top and Bottom and on horizontal mode = Left and Right
    • Screenshot_20200302-121054.jpgScreenshot_20200302-120951.jpgezgif.com-resize.gif
  • 1.04
    • Add getCurrentIndex - gets the current tab index
    • Add getTabBackgroundColor and setTabBackgroundColor - gets or sets the tab background color
  • 1.05
    • Adds a short description about a property
    • Add get and set Badge_Visible - shows or hide a badge on a tab
      • Screenshot_20200325-161959.jpg
      • Screenshot_20200325-162119.jpg
        Screenshot_20200325-162212.jpg
        Screenshot_20200325-162239.jpg
    • Add get and set Badge_Height - set the size of the badge
    • Add set Badge_Text - sets the badge number, set it to -1 to have only the color
    • Add get Badge_getLabel - gets the badge label, to modify it to your own
    • Add get and set Badge_Color - gets or sets a badge color
    • Add set Badge_setVisibleEasy - shows the badge with all important parameters to save lines of code
    • 1.06
      • Badge Bug Fixing
      • Add get and set Badge_Gravity
      • Add enums. for the Badge_Gravity
        • Badge_MIDDLERIGHT
        • Badge_MIDDLELEFT
        • Badge_TOPRIGHT
        • Badge_TOPMIDDLE
        • Badge_TOPLEFT
    • 1.07
      • Icon Size is now smaller
      • Badge Bug Fixing
    • 1.08
      • Add Commit Mode Designer Property
        • CommitMode_MANUALLY - you need to call CommitChanges if you make changes
        • CommitMode_AUTOMATIC - The view is refreshing automatically after you make changes on the view
      • Add CommitChanges Property
    • 1.09
      • Add Public Variable: text_font - change the font of the text
    • 1.10
      • TabClick Bug Fix if withHalo = false
  • 1.11
    • Add TextIcon_Padding public variable - if you need more space between text and icon
      • default is 1.3
  • 1.12
    • B4I Underline Bug Fix
  • 1.13
    • Add VisibleAt -Shows or Hide a tab
    • Add Support for Icons or Text mixed
      • Screenshot_20200723-164537.jpg
    • Add TabStripMode - if true, then the underline width/height is the full tab
      • Screenshot_20200723-170306.jpg
    • Example is now based on B4XPages
  • 1.14
    • Add ViewEnable - enable or disable the view
  • 1.15
    • B4A only - BugFix if the text is too long
    • B4A only - new dependency "Reflection"
    • B4I only - ViewEnable BugFix
  • 1.16
    • Add RemoveAllTabs
  • 1.20
    • Add get/set HaloDuration
    • Add setBadge_setLeftPadding
    • B4I Better handling of icons - looks now better
    • B4A and B4J The view can now also have round corners - added SetCircleClip
      • on B4J you need to set setCornerRadius
    • B4A and B4I New Icon Tint Function, the quality of icons with a new color is now better
    • B4A and B4I BitmapCreator is no longer required
  • 1.21
    • BugFixes
  • 1.22
    • Adds BorderPadding - if you want a border, then set the BorderWidth here for the padding
  • 1.23 (read more)
    • Add BeginUpdate - Call this if you remove or add tabs, no events or animations during this
    • Add EndUpdate - Call this if you finished adding or removing tabs
    • BugFixes
  • 1.24
    • core iif function is now used
Have Fun :)
 

Attachments

  • AS Tab Menu Example.zip
    180.5 KB · Views: 202
  • ASTabMenu.b4xlib
    9.1 KB · Views: 177
Last edited:

Alexander Stolte

Expert
Licensed User
Update
  • 1.13
    • Add VisibleAt -Shows or Hide a tab
    • Add Support for Icons or Text mixed
      • Screenshot_20200723-164537.jpg
    • Add TabStripMode - if true, then the underline width/height is the full tab
      • Screenshot_20200723-170306.jpg
    • Example is now based on B4XPages
Hide a Tab:
ASTabMenu_horizontal.VisibleAt(1,False)

How to use icons or text at the same time?
B4X:
ASTabMenu_horizontal.AddTab(xui.Color_ARGB(255,39, 174, 97),"",ASTabMenu_horizontal.FontToBitmap(Chr(0xF015),False,30,xui.Color_White),"")
ASTabMenu_horizontal.AddTab(xui.Color_ARGB(152,39, 174, 97),"Test1",Null,"")
  1. Set TabStyle to TextIcon
  2. if you want a icon then write "" on the text parameter
    1. if you want text then write Null to the icon parameter
 

angel_

Well-Known Member
Licensed User
I've noticed that if you have tabs with icons and others with icons+text, the latter are overlapped, I don't know if it's a bug or this is not possible to do.

Another issue is that if the tab text is long in B4A it doesn't truncate the text to one line
 

Alexander Stolte

Expert
Licensed User
I've noticed that if you have tabs with icons and others with icons+text, the latter are overlapped, I don't know if it's a bug or this is not possible to do.
An image would be nice. Or make sure that you have read this:
B4X:
ASTabMenu_horizontal.AddTab(xui.Color_ARGB(255,39, 174, 97),"",ASTabMenu_horizontal.FontToBitmap(Chr(0xF015),False,30,xui.Color_White),"")
ASTabMenu_horizontal.AddTab(xui.Color_ARGB(152,39, 174, 97),"Test1",Null,"")
  1. Set TabStyle to TextIcon
  2. if you want a icon then write "" on the text parameter
    1. if you want text then write Null to the icon parameter
Another issue is that if the tab text is long in B4A it doesn't truncate the text to one line
i have fixed it, but the problem is, now you need on B4A the Reflection lib. too, only for this...
 

Kope

Member
Licensed User
Hi I keep getting this error using this lib on b4i


Copying updated assets files (1)
Application_Start
Error occurred on line: 128 (ASTabMenu)
Expected: UIView, object type: B4ILayoutValues
Stack Trace: (
CoreFoundation E2D6A76B-6879-31A3-8168-DF49F94E17CD + 1222248
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation E2D6A76B-6879-31A3-8168-DF49F94E17CD + 133720
LED MUSIC -[B4IObjectWrapper setObject:] + 276
LED MUSIC -[B4XViewWrapper setObject:] + 152
LED MUSIC +[B4IObjectWrapper createWrapper:eek:bject:] + 108
LED MUSIC -[b4i_dashboard _show] + 1068
LED MUSIC -[b4i_main _application_start:] + 2928
CoreFoundation E2D6A76B-6879-31A3-8168-DF49F94E17CD + 1247424
CoreFoundation E2D6A76B-6879-31A3-8168-DF49F94E17CD + 6768
LED MUSIC +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
LED MUSIC -[B4IShell runMethod:] + 448
LED MUSIC -[B4IShell raiseEventImpl:method:args::] + 2172
LED MUSIC -[B4IShellBI raiseEvent:event:params:] + 1580
LED MUSIC __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib 361DA09A-E7CE-30EB-8DFC-9D9AF9DE4A0A + 371112
libdispatch.dylib 361DA09A-E7CE-30EB-8DFC-9D9AF9DE4A0A + 374052
libdispatch.dylib 361DA09A-E7CE-30EB-8DFC-9D9AF9DE4A0A + 255740
CoreFoundation E2D6A76B-6879-31A3-8168-DF49F94E17CD + 689852
CoreFoundation E2D6A76B-6879-31A3-8168-DF49F94E17CD + 669072
CoreFoundation CFRunLoopRunSpecific + 424
GraphicsServices GSEventRunModal + 160
UIKitCore UIApplicationMain + 1932
LED MUSIC main + 124
libdyld.dylib 0CB11832-70AD-3EC6-A191-AFB85E3BF348 + 6384
)
 

Alexander Stolte

Expert
Licensed User
I saw that I had not published 3 updates...
Update
  • 1.20
    • Add get/set HaloDuration
    • Add setBadge_setLeftPadding
    • B4I Better handling of icons - looks now better
    • B4A and B4J The view can now also have round corners - added SetCircleClip
      • on B4J you need to set setCornerRadius
      • New shape function.JPG
    • B4A and B4I New Icon Tint Function, the quality of icons with a new color is now better
    • B4A and B4I BitmapCreator is no longer required
 

Rubsanpe

Active Member
Licensed User
I saw that I had not published 3 updates...
Update
  • 1.20
    • Add get/set HaloDuration
    • Add setBadge_setLeftPadding
    • B4I Better handling of icons - looks now better
    • B4A and B4J The view can now also have round corners - added SetCircleClip
    • B4A and B4I New Icon Tint Function, the quality of icons with a new color is now better
    • B4A and B4I BitmapCreator is no longer required
Hi. Very good work. I can't see "B4A and B4J The view can now also have round corners - added SetCircleClip" at this 1.20 version. Not in designer and not in methods.

Rubén
 
Top