Git Product home page Git Product logo

meowbottomnavigation's Introduction

Meow Bottom Navigation

A simple & curved & material bottom navigation for Android written in Kotlin with ♥ .

Download

Update your build.gradle (project path) like below :

buildscript {
    repositories {
        jcenter()
    }
}

Update your build.gradle (module path) like below :

dependencies {
  implementation 'com.etebarian:meow-bottom-navigation:1.3.1'
}

Use androidx by adding this lines to gradle.properties. If you want more info, just google AndroidX.

android.useAndroidX=true
android.enableJetifier=true

If you want to add this library to a JAVA Project, you must add kotlin library to build.gradle.

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
}

😍 Donate & Support

We are developing this framework in open source community without financial planning but the maintenance & preparing updates at periodic times is Time-consuming. If you like this project and you want to give us peace of mind, you can support us by clicking this button :

Usage

Add Meow Bottom Navigation in you layout xml file.

<meow.meowbottomnavigation.MeowBottomNavigation
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

Add menu items in code.

val bottomNavigation = findView(R.id.bottomNavigation)
bottomNavigation.add(MeowBottomNavigation.Model(1, R.drawable.ic_home))
bottomNavigation.add(MeowBottomNavigation.Model(2, R.drawable.ic_explore))
bottomNavigation.add(MeowBottomNavigation.Model(3, R.drawable.ic_message))

Add vectorDrawables.useSupportLibrary = true to your build.gradle inside defaultConfig{ ... } to use vector drawable icons.

Customization

<com.etebarian.meowbottomnavigation.MeowBottomNavigation
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:mbn_circleColor="#ffffff"
    app:mbn_backgroundBottomColor="#ffffff"
    app:mbn_countBackgroundColor="#ff6f00"
    app:mbn_countTextColor="#ffffff"
    app:mbn_countTypeface="fonts/SourceSansPro-Regular.ttf"
    app:mbn_defaultIconColor="#90a4ae"
    app:mbn_rippleColor="#2f424242"
    app:mbn_selectedIconColor="#3c415e"
    app:mbn_shadowColor="#1f212121"
    app:mbn_hasAnimation="true"    
/>
  • You can change this properties in Kotlin/Java Realtime⌚.

Listeners

Use setOnShowListener() function to access when a cell has been shown.

bottomNavigation.setOnShowListener {
    // YOUR CODES
}

Use setOnClickMenuListener() function to access when a cell has been clicked.

bottomNavigation.setOnClickMenuListener {
    // YOUR CODES
}

If you are Java Developer, use this examples :

bottomNavigation.setOnClickMenuListener(new Function1<MeowBottomNavigation.Model, Unit>() {
            @Override
            public Unit invoke(MeowBottomNavigation.Model model) {
                // YOUR CODES
                return null;
            }
        });

bottomNavigation.setOnShowListener(new Function1<MeowBottomNavigation.Model, Unit>() {
            @Override
            public Unit invoke(MeowBottomNavigation.Model model) {
                // YOUR CODES
                return null;
            }
        });

Counter Badge

Set counter badge on a specific cell by setCount(Int,String).

bottomNavigation.setCount(CELL_ID, YOUR_STRING)

Clear counter badge on a specific cell by clearCount(Int).

bottomNavigation.clearCount(CELL_ID)

Clear all counter badges on a specific cell by clearCount(Int).

bottomNavigation.clearAllCounts(TAB_ID)

Set Default CELL

Use this function :

bottomNavigation.show(CELL_ID)

meowbottomnavigation's People

Contributors

onehamidreza avatar theapache64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meowbottomnavigation's Issues

Issue when declare Listener in OnCreate

I found this issue:

when i create the class first to do is init the component like this:

bottomMenu!!.add(MeowBottomNavigation.Model(1, R.drawable.ic_facebook)) bottomMenu!!.add(MeowBottomNavigation.Model(2, R.drawable.ic_twitter)) bottomMenu!!.add(MeowBottomNavigation.Model(3, R.drawable.ic_instagram)) bottomMenu!!.setOnShowListener { when(it.id){ OPC1 -> onClickMenu(it.id) OPC2 -> onClickMenu(it.id) OPC3 -> onClickMenu(it.id) else -> "" } } bottomMenu!!.show(1, true)

But the issue begin when the app is running the OnClickMenu() in OPC1 execute 5 times... why ??

Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.etebarian.meowbottomnavigation.MeowBottomNavigation

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alialfayed.facerecognition/com.alialfayed.facerecognition.view.activity.HomeActivity}: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.etebarian.meowbottomnavigation.MeowBottomNavigation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.etebarian.meowbottomnavigation.MeowBottomNavigation
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class com.etebarian.meowbottomnavigation.MeowBottomNavigation

How to use dynamic Images got from api as icon

Is there any way we can make Icons and Texts dynamic in this?. I am getting bitmap from Api end but in this api we can only use vector Drawables. If there is any possibilities than please help

show method error

// when click on item 3 , set current item = 1
bottomNavigation.show(1,true);

This function has a problem
Screenshot_1559064773

Notification badge is too close to the top of the bar

The circle showing the notification count has no space at all from the top of the bar itself. Doesn't look aesthetic. Is there a way to create a gap without copying the whole project? It could use like a 2dp margin

Keypad closes as soon as editText is focused in fragment

UI & animations are damn good in this library. Coming to the issue, I'm calling a fragment when one of the menu items are clicked and Keypad keeps closes as soon as editText is focused in that fragment. I checked it many a times but, result is same. Can you help me in fixing this please?

How to use it in Java?

Actually I haven't used kotlin till yet and doesn't ever wanna bother but, you did such a great job so I wanna implement it in my existing project.

Wann to know how to add nav menu items in java and call it from Java code.

Thanx in Advance

From Kotlin to Java

Please, upload a full source of java for this project. Many of us who code in java can't understand the kotlin code, there is not enough source to convert kotlin to java. The ByteCode are also so confusing. Please, update it for java also.

Selected button background

Hello Hamidreza.
I'm using your awesome BottomNavigation.
Now, I want to set background color for selected button.
Is this possible? Can you help me on this?

tnx (:

Programmatically hide button

I'm trying this bottom navbar and it's beautiful, but it doesn't have the possibility to handle hiding of opened button programmatically ( example: add fragment to stack and press back to return main page)

added solution to use in java project.

Capture
i got error and i cannot resolve getId() error

I use 1.8 java in gradle still lamda function got error
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

can you give this bottom navigation code in java language too.

default selected icon

Hi
how can i set default selected icon !? i mean is it possible to choose default icon when parent activity starts working

Set count

When i set a value for count, layout is refresh. Why is happened? How can i prevent this?

java.lang.IllegalArgumentException: Invalid Transition types

I am getting crash with this error :


 java.lang.IllegalArgumentException: Invalid Transition types
        at androidx.fragment.app.FragmentTransition.chooseImpl(FragmentTransition.java:465)
        at androidx.fragment.app.FragmentTransition.configureTransitionsOrdered(FragmentTransition.java:321)
        at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:138)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1866)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)

Add text

can we add text below the icons?

How to use navigation graph?

Hi there, I just wanna use this just like android default bottomNavigation in my code:
------------------xml-------------
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav" />

------------------------activity--------------
navController = Navigation.findNavController(this , id.home_nav_host_fragment)

binding.bottomNav.setupWithNavController(navController)

NavigationUI.setupActionBarWithNavController(this , navController)

setOnShowListener issue

I have used this library and set its onShowLisener and its OnClickMenuListener it works for many times but for sometimes when one item selected it does not work and by second or third click it'll work.
thanks

Parent layout not transparent background

Hello,
When I using this lib, BottomNav have a like grey background like picture below.
84480506_998877583817121_8423627368035254272_n

How can I transparent it? Because this color is different my background color, so not good.
Thanks!

keyboard does not open, when i using this library

Hello guys, I am using this library in an activity and show fragment on a frame layout when user click on any button of bottom navigation. when user want to type anything in any editText, keyboard does not open by showing this message in logcat:
2020-02-06 07:38:20.352 3650-3650/com.tivasoft.myorder W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
and keyboard closed.

Remove count badge

Say i have a count of 0 (zero) how do i remove the badge from the icon?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.