Giter Club home page Giter Club logo

nicebottombar's Introduction

NiceBottomBar

A lightweight Android material bottom navigation bar library

API

GIF

Usage

  • Create menu.xml under your res/menu/ folder
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

	<item
		android:id="@+id/item0"
		android:title="@string/servers"
		android:icon="@drawable/ic_dns_black_24dp" />

	<item
		android:id="@+id/item1"
		android:title="@string/search"
		android:icon="@drawable/ic_search_black_24dp" />

	<item
		android:id="@+id/item2"
		android:title="@string/billing"
		android:icon="@drawable/ic_receipt_black_24dp" />

	<item
		android:id="@+id/item3"
		android:title="@string/account"
		android:icon="@drawable/ic_account_circle_black_24dp" />
    
</menu>
  • Add view into your layout file
<me.ibrahimsn.lib.NiceBottomBar
	android:id="@+id/bottomBar"
	android:layout_width="match_parent"
	android:layout_height="60dp"
	app:menu="@menu/bottom_menu" />
  • Use NiceBottomBar functions in your activity
bottomBar.setActiveItem(1)
bottomBar.setBadge(2)
bottomBar.removeBadge(2)

bottomBar.onItemSelected = {
    status.text = "Item $it selected"
}

bottomBar.onItemReselected = {
    status.text = "Item $it re-selected"
}

bottomBar.onItemLongClick = {
    status.text = "Item $it long click"
}

OR

bottomBar.setOnItemSelectedListener(object: OnItemSelectedListener {
    override fun onItemSelect(pos: Int) {
        status.text = "Item $pos selected"
    }
})

bottomBar.setOnItemReselectedListener(object: OnItemReselectedListener {
    override fun onItemReselect(pos: Int) {
        status.text = "Item $pos re-selected"
    }
})

bottomBar.setOnItemLongClickListener(object: OnItemLongClickListener {
    override fun onItemLongClick(pos: Int) {
        status.text = "Item $pos long click"
    }
})

Use in Java

NiceBottomBar bottomBar = (NiceBottomBar) findViewById(R.id.bottomBar);

bottomBar.setOnItemSelectedListener(new OnItemSelectedListener() {
     @Override
     public void onItemSelect(int pos) {
	// Do action
     }
});

bottomBar.setOnItemReselectedListener(new OnItemReselectedListener() {
     @Override
     public void onItemReselect(int pos) {
	// Do action
     }
});

bottomBar.setOnItemLongClickListener(new OnItemLongClickListener() {
     @Override
     public void onItemLongClick(int pos) {
	// Do action
     }
});

Customization

<me.ibrahimsn.lib.NiceBottomBar
	android:id="@+id/bottomBar"
	android:layout_width="match_parent"
	android:layout_height="60dp"
	app:menu="@menu/bottom_menu"
	app:backgroundColor=""
	app:indicatorEnabled=""
	app:indicatorColor=""
	app:indicatorWidth=""
	app:indicatorGravity=""
	app:itemFontFamily=""
	app:textColor=""
	app:textColorActive=""
	app:textSize=""
	app:iconSize=""
	app:iconMargin=""
	app:activeItem=""
	app:badgeColor=""
	app:indicatorInterpolator="anticipateOvershoot" />

Setup

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

dependencies {
        implementation 'com.github.ibrahimsn98:NiceBottomBar:2.2'
}

License

MIT License

Copyright (c) 2019 İbrahim Süren

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Follow me on Twitter @ibrahimsn98

nicebottombar's People

Contributors

brookmg avatar ibrahimsn98 avatar jasonlovedl avatar romain25 avatar yangjinlalala 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

nicebottombar's Issues

Add callback for longclick event

When I want to add a new function to handle the long click event. So I think to add a long-click callback function in Interface BottomBarCallback will be more convenient to add new feature about that.

Custom Font

please add feature to set custom font from assets

How to use this in java

The code is not working for java

niceBottomBar.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
          @Override
          public void onItemSelect(int pos) {
          }
      });

Error
No candidates found for method call niceBottomBar.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() { @OverRide public void onItemSelect(int pos) { } }).

BottomBar bottom margin

tnx for lib 👍
when indicator is disabled, bottom margin that used for indicator must be 0

Layout direction doesn't change

I am building an app that should work for English, Arabic and Habrew.
When changing the system to Arabic/Hebrew, the layout remains in the same order.

I've tried setting the layoutDirection to inherit, locale, rtl or ltr, but it all remains the same.

Other than that the library is amazing, thank you!

how to handle click on menu items

i dont know how handle click on menu items, you defined "onItemSelect" but i can't figure out how to do it
please help me if you can :)

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.