B4A Library BottomNavigation

This is a wrap for this Github project.

BottomNavigation
Author:
DonManfred (wrapper)
Version: 1
  • BottomNavigation
    Events:
    • onNavigationItemClick (index As Int)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • GetApplicationDrawableID (DrawableName As String) As Int
      Get a Drawable from the Application Resources.
      Returns Null if the Drawable is not found.
    • 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)
    • addTab (item As BottomNavigationItem)
    • isColoredBackground (coloredBackground As Boolean)
    • isWithText (withText As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • ItemActiveColorWithoutColoredBackground As Int [write only]
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • BottomNavigationItem
    Methods:
    • Initialize (title As String, color As Int, imageResource As String)
    • IsInitialized As Boolean
    • setImageResource (imageResource As String)
    Properties:
    • Color As Int
    • ImageResource As Int [read only]
    • Title As String
  • BottomNavigationUtils
    Methods:
    • Initialize
    • IsInitialized As Boolean
    • backgroundColorChange (view As View, fromColor As Int, toColor As Int)
    • changeTextColor (textView As TextView, fromColor As Int, toColor As Int)
    • changeTextSize (textView As TextView, from As Float, to As Float)
    • changeTopPadding (view As View, fromPadding As Int, toPadding As Int)
    • imageColorChange (image As ImageView, fromColor As Int, toColor As Int)

gifView2.gif
 

Attachments

  • BottomNavigationEx.zip
    11.2 KB · Views: 1,402
  • BottomNavigationV1.0.0.zip
    18.6 KB · Views: 1,034
  • BottomNavigationExViewPager.zip
    11.4 KB · Views: 1,172
  • BottomNavigationV1.1.zip
    24.2 KB · Views: 1,247
Last edited:

Claudio Oliveira

Active Member
Licensed User
Longtime User
Amazing, Manfred.
Your sample project is raising this error message though
B4X:
lib: NOTFOUND 'navigation_onnavigationitemclick

Regards

SOLVED: There is no "onNavigationItemClick" sub in the original sample project. After creating this sub, it worked just fine.

Thanks!
 
Last edited:

asales

Expert
Licensed User
Longtime User
Really nice!
Works only in Android 5+?
I tried in versions 5 and 6 and works fine, but I have issues in 4.0 and 4.4.
In 4.0 the navigation was not showed.
In 4.4 I don't see the icons and I have a little dark space in the top of navigation and a white space in the bottom.
botnav1.png
 

DonManfred

Expert
Licensed User
Longtime User
the line #AdditionalRes: ..\Resource is for load what?
To load the additional resources for this object.

See content of folder Resource.
Here you can place the pngs to use in the drawables folder.
Additional the resource folder holds the layout of the button bar in folder Layout and the objectstructure in attr.xml
 

Daniel-White

Active Member
Licensed User
Longtime User
Thanks you for your reply. DonManfred.

I am a little bit confused, because in /Resource has the files, all of them are there, but the IDE show this:
Perhaps my android-support-v4.jar in Additional Libraries is out to date?, or the SDK 19 and need newest SDK version.
What do you think? say " in package android" mmm

B4A version: 5.80
Parsing code. (0.00s)
Compiling code. (0.03s)
Compiling layouts code. (0.00s)
Generating R file. Error
..\resource\drawable\github_circle.xml:2: error: No resource identifier found for attribute 'viewportWidth' in package 'android'
..\resource\drawable\github_circle.xml:2: error: No resource identifier found for attribute 'viewportHeight' in package 'android'
..\resource\drawable\github_circle.xml:7: error: No resource identifier found for attribute 'fillColor' in package 'android'
 

Tayfur

Well-Known Member
Licensed User
Longtime User
try to update you android-support-v4.jar
I revcived an error.

Untitled.png


B4X:
 Navigation.Initialize("Navigation")
  
   Activity.AddView(Navigation,0,60%y,100%x,20%y)
  
   Navigation.ItemActiveColorWithoutColoredBackground = Colors.Gray
    Navigation.Color = Colors.DarkGray
    Navigation.isColoredBackground(True)

    Dim Item As BottomNavigationItem
    Item.Initialize("Favorite",Colors.Blue,"ic_favorite_black_24dp")
    Navigation.addTab(Item)

    Dim Item As BottomNavigationItem
    Item.Initialize("Github",Colors.Blue,"github_circle")
    Navigation.addTab(Item)

    Dim Item As BottomNavigationItem
    Item.Initialize("Favorite",Colors.Blue,"ic_favorite_black_24dp")
    Navigation.addTab(Item)
 

Tayfur

Well-Known Member
Licensed User
Longtime User
Did you added the Resourcefolder from the sample? Did you added the #Additionalres command in your project?

Now I added folder.

Code break down on this line and app stoped.
Navigation.ItemActiveColorWithoutColoredBackground = Colors.Gray


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)
 

paragkini

Member
Licensed User
Longtime User
I want to use IME with this and tried using
IME_HeightChanged (NewHeight As Int, OldHeight As Int) event. But log says "Ignoring event: ime_heightchanged".
any reason?
 

DonManfred

Expert
Licensed User
Longtime User
any reason?
I don´t know.

But your issue seems not to be related to the bottomnavigationlib.
There is no HeightChanged event which is raised by the lib. Maybe it is part of the b4a viewWrapper Class...

You should start a new thread in the questionsforum for your issue. Maybe post some example code which shows the problem.
 

fredo

Well-Known Member
Licensed User
Longtime User
This looks very promising. But for the Icons I find the hassle with the vector drawables (in xhdpi, xxhdpi, xxxhdpi) very unproductive.
I would like to use Android-Iconics icon font (introduced by thedesolatesoul with the MSMaterialDrawer).

Since the Navigation Items only work with imageResource I need to find a way to use the icon font for the BottomNavigationItems.


  • BottomNavigationItem
    Methods:
    • Initialize (title As String, color As Int, imageResource As String)
    • IsInitialized As Boolean
    • setImageResource (imageResource As String)
    Properties:
    • Color As Int
    • ImageResource As Int [read only]
    • Title As String


Would it be possible to extend the library to accept icon fonts?


Or do you know another way of doing that?
 
Last edited:
Top