ibrahimsn98 / smoothbottombar Goto Github PK
View Code? Open in Web Editor NEWA lightweight Android material bottom navigation bar library
License: MIT License
A lightweight Android material bottom navigation bar library
License: MIT License
As per new guidelines by developer.android.com, Now BottomNavigationView is operated using ViewModel and NavController but SmoothBottomBar is unable to support that
error: no suitable method found for setupWithNavController(SmoothBottomBar,NavController)
NavigationUI.setupWithNavController(navView, navController);
method NavigationUI.setupWithNavController(Toolbar,NavController) is not applicable
(argument mismatch; SmoothBottomBar cannot be converted to Toolbar)
method NavigationUI.setupWithNavController(NavigationView,NavController) is not applicable
(argument mismatch; SmoothBottomBar cannot be converted to NavigationView)
method NavigationUI.setupWithNavController(BottomNavigationView,NavController) is not applicable
How ?
I want to show bottom bar item when user login check type of login user and based on user i want to show 2 tab or 3 tab dynamically change bottom items
I try to add its dependencies in my existing project but its not getting added.
How to add notification badge on Bottom Navigation View?
Usually we do this :
val navBar = findViewById<BottomNavigationView>(R.id.bottom_navigation)
navBar.getOrCreateBadge(R.id.action_stamp).number = 2
Anyway to set this bottom bar with a viewpager ? So that I can swipe back and forth between fragments ?
My project is not currently supporting Android X.
Hence while integrating library, I am getting following build error:
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.1.0] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
Is there any support before Android X for this library?
Thanks.
I just tried to test my app interface, but it does not seem espresso can detect it. Neither manually code the test nor using record test (which is works when i use default navigation bar component). Anyone has tried to test it? Any workaround is appreciated since this library has good looking design for me.
How can we change the font family and change it to custom font in SmoothBottomBar? Please help.
I have a requirement to hide the Fragment and its Icon in BottomNavigationBar if the boolean value is true. if(hideFrag){ select_fragment=null; }else{ select_fragment = new Fragment4();}
this one just hides the fragment but not the icon how to deal with it.
Item name that has more than 6 character cant be expanded? what to do with that?
How can we use this as an icon top and text bottom?
i m using java in my current project along with navigation component but the library not seems to be working with nav component
setCurrentItem method is missing from the SmoothBottomBar class. This is required if I want to manually switch the tab programmatically.
Similarly getCurrentItem method is missing as well.
Please provide some workaround for this.
Thanks
Hello @ibrahimsn98 @rezaepsilon0 @mayokunthefirst @brookmg @tobiasschuerg
Please look in to this issue, Bottom and action bar menus are same, if user want to show other menu option in toolbar with icon, then how they will show, because menu already occupied with bottom navigation. without this solution library not useful for live projects or apps, please solve that.
Thanks
Well done, you've done a great work. I was using SmoothBottomBar in my mTodo and I needed to change the icon margin, but it was not exposed to xml attrs. I had to fork and increase the value inside Constnats.kt
. It would be nice to have control over it dynamically. I will submit a pull request for that matter. Keep good work up ๐๐ป
[PR: #36 ]
Currently I'm using animate();, if it gets a native show/hide option to be used along with the recycler view scroll behavior it might work more efficiently
How can I add Notification Badge to particular tab
Great work bro. How can I adapt this library with a TabLayout activiy
HOW TO Show Fragment pless
This library is amazing, I really want to try it, but I won't kotlin.Can you help me?
Thank you.
Device Info - Samsung Galaxy M10s, Android 10
-one thing I like to share here is I noticed that error occurred when the device is offline and I noticed this issue in -
Redmi Note 8, Android Version 9
In xml -
<me.ibrahimsn.lib.SmoothBottomBar
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?background_default_darker"
android:layout_marginBottom="12dp"
app:cornerRadius="8dp"
app:elevation="12dp"
app:iconSize="24dp"
app:iconTint="@color/grey500"
app:iconTintActive="@color/black"
app:indicatorColor="@color/greyF6"
app:itemFontFamily="@font/poppins"
app:menu="@menu/bottom_nav_home"
app:textColor="@color/black" />
In menu items, I used vector drawable.
crash info -
java.lang.IndexOutOfBoundsException: Empty list doesn't contain element at index 0.
at kotlin.collections.EmptyList.get(Collections.kt:35)
at kotlin.collections.EmptyList.get(Collections.kt:23)
at me.ibrahimsn.lib.SmoothBottomBar.onDraw(SmoothBottomBar.kt:391)
at android.view.View.draw(View.java:23191)
at android.view.View.updateDisplayListIfDirty(View.java:22066)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.draw(View.java:23194)
at android.view.View.updateDisplayListIfDirty(View.java:22066)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22052)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1277)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.draw(View.java:23194)
at android.view.View.updateDisplayListIfDirty(View.java:22066)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at androidx.drawerlayout.widget.DrawerLayout.drawChild(DrawerLayout.java:1426)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22052)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22052)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22052)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22052)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.updateDisplayListIfDirty(View.java:22052)
at android.view.View.draw(View.java:22921)
at android.view.ViewGroup.drawChild(ViewGroup.java:5230)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4987)
at android.view.View.draw(View.java:23194)
at com.android.internal.policy.DecorView.draw(DecorView.java:1117)
at android.view.View.updateDisplayListIfDirty(View.java:22066)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:588)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:594)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:667)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4267)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4051)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3324)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2204)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9003)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:996)
at android.view.Choreographer.doCallbacks(Choreographer.java:794)
at android.view.Choreographer.doFrame(Choreographer.java:729)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7860)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
How can the language of the items be changed programmatically, since it does not allow me to do it only does it with an element.
I hope you can help me, Thanks!
Hey,
Great looking bottom bar you got here. I took a look by adding it to an empty template app from Android Studio 4 and it doesn't seem to work. The bar appears but it stays on the first tab.
I stopped here to test it to see how it feels but as I say nothing happens when you touch any part of the bar. Pity.
Best of luck with it
Hello i tried this library for my project, but I am unable to use onItemSelected function. Instead i get setOnItemSelected function but couldn't understand it as to how to use it. Please help. How do i switch fragment when bottombar item changes, in Java. Please help.
setOnItemSelectedListener or onItemSelectedListener not working in fragment
i'm getting unresolved reference.
i'm using it as
userType.setOnItemSelectedListener(object : OnItemSelectedListener{ override fun onItemSelect(pos: Int): Boolean { TODO("Not yet implemented") } })
hi
how i can deselect all items
ERROR: Failed to resolve: com.github.ibrahimsn98:SmoothBottomBar:1.2
Show in Project Structure dialog
Affected Modules: app
Can we also please have a java version if the library. This library is awesome but java developers like me can't take it in use.
When setting activeItem
from XML I expect it to set that item active at startup, I can clearly see that at first startup, item at position 0
is set then item at position which I set in XML will be set as active.
Don't let quality and low frame rate of GIF fool you I already tested this situation in several devices and android versions also in an Emulator in a decent computer.
BTW I took the liberty of inspecting your library source and as I guessed initial value for activeItem
is 0
which explains the situation where at first initial active item is 0
, investing further there's a setter method for another variable coupled with that which shows applyItemActiveIndex()
method which I guess is responsible for changing active item index and animations for that matter. further trace shows that itemActiveIndex
is set to attribute from XML and in setter method of itemActiveIndex
, as explained recently applyItemActiveIndex()
is called so I don't see why first item at position 0
is set as active then item at position where developer set from XML so it seems to me code is OK except that maybe onSizeChanged
method is called in initial view creation and in that method this line (applyItemActiveIndex
) is called so maybe this is causing the issue. I'm not sure about view lifecycle so how can that method being called before object consternation is beyond me, I should investigate more.
hello
when i use indicator color , all thing (icon, text) disappear !! how solve it ?
I was populating the bottom navigation with the menu, all my items did not have an icon as I planned to add them later on. The bottom navigation kept on crashing with the main error as follows:
Error inflating class me.ibrahimsn.lib.SmoothBottomBar
After a closer look into the logcat revealed the following error:
Caused by: kotlin.KotlinNullPointerException at me.ibrahimsn.lib.BottomBarParser.getTabConfig(BottomBarParser.kt:48) at me.ibrahimsn.lib.BottomBarParser.parse(BottomBarParser.kt:23)
After a few hours of debugging and looking through your code, I figured out that the library is trying to load icon and not finding any. Please put a note in the library description or handle it with a try-catch.
PS: Very Cool Library, great work.
Happy Coding.
when i use navigation component , the onDestroy() method called every time get back to fragment and recreate fragment !
Hi
How can I keep the text in the menu visible always? even if it is selected or not selected.
Hi,
Thank you for the great work you've done with this library!
I use it and it almost fits with the designer's expectations.
The only problem I'm facing is I need to show the full text without shortening it.
Is it currently possible?
If not, I think it could be a nice feature!
How to change background shape from drawable resource file, maybe we want to use custom background that rounded in topLeftCorner and topRightCorner.
Can you create a function for get active item like setActiveItem. Thanks
very cool !! lib.
i am using NoActionBar theme(i.e Theme.AppCompat.Light.NoActionBar / Theme.MaterialComponents.Light.NoActionBar) in this case fragment is not changing according to menu item. In DarkActionBar it works fine.
I am a newbie and am currently working with a single activity and multiple fragments pattern. I want to integrate this smooth bar with the navController.
I tried doing this:
bottomBar.onItemSelected = {
when (it) {
0 -> navController.navigate(R.id.someFragment)
1 -> navController.navigate(R.id.someOtherFragment)
else -> navController.navigate(R.id.someFragment)
}
}
But this would create a new fragment every time instead of using the existing fragment in the navigation stack. I looked up the documentation and it only teaches how to integrate it with the bottom navigation view they provided.
Is it possible to somehow setup the nav controller? And if not, are there any workarounds?
I use bottom navigation without toolbar and when I press on buttomnav some times and back , I will back reverse
If I clicked 5 time random buttom in SmoothBottomBar so must press on back button 5 times too back to original fragment
I tried rtl but it doesn't worked
i wish we could manually set items. menu does not allow font change and is not flexible.
Can we integrate this in MVVM architecture using data binding?
Hy, It is a great library, but i can not code in kotlin. So my question is: Is there perhaps a java version of this library? If so, than could you please link it for me?
Thank you for your answer!
When you hardcode title value in bottom_menu.xml, it crashes the app because of resourse not found exception.
Please add the handling for reading hardcoded value in addition of reading from strings.xml.
how can i set badge for every item? (with navigation component)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.