• Stars
    star
    1,461
  • Rank 30,995 (Top 0.7 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created about 8 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bottom Navigation widget component inspired by the Google Material Design Guidelines at https://www.google.com/design/spec/components/bottom-navigation.html

Material Bottom Navigation Library

Android Arsenal Build Status
Maven Central

Lightweight Bottom Navigation library component inspired by the Google Material Design Guidelines at https://www.google.com/design/spec/components/bottom-navigation.html

This project is also inspired by https://github.com/roughike/BottomBar


Table of contents

Installation

In your project's build.gradle file add the following line to the dependencies group:

compile 'it.sephiroth.android.library.bottomnavigation:bottom-navigation:3.0.0'

Usage

Usage of the BottomNavigation widget is very easy. Just place it in your layout.xml like this:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/CoordinatorLayout01"
	xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
	android:layout_height="match_parent"
    android:fitsSystemWindows="true">

	...your content...

    <it.sephiroth.android.library.bottomnavigation.BottomNavigation
	    android:id="@+id/BottomNavigation"
        android:layout_width="match_parent"
	    android:layout_height="wrap_content"
        android:layout_gravity="bottom"
	    app:bbn_entries="@menu/bottombar_menu_4items"
        app:bbn_scrollEnabled="true"
        app:bbn_badgeProvider="@string/bbn_badgeProvider"
	    app:layout_behavior="@string/bbn_phone_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

All the menu main configurations are defined within the xml menu resource itself. Here's an example of a menu with 4 items:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@android:color/black"
    app:bbn_badgeColor="#FFFF0000"
	app:bbn_rippleColor="#33ffffff">
    <item
	    android:id="@+id/bbn_item1"
    	android:color="@color/colorPrimary"
        android:icon="@drawable/ic_cloud_off_white_24dp"
	    android:title="Cloud Sync" />
    <item
	    android:id="@+id/bbn_item2"
        android:color="@android:color/holo_green_dark"
	    android:icon="@drawable/ic_cast_connected_white_24dp"
        android:title="Chromecast" />
	<item
        android:id="@+id/bbn_item3"
	    android:color="@android:color/holo_orange_dark"
        android:icon="@drawable/ic_mail_white_24dp"
	    android:title="Mail" />
    <item
	    android:id="@+id/action4"
    	android:color="#FF5252"
        android:icon="@drawable/ic_format_list_numbered_white_24dp"
	    android:title="List" />
</menu>

Examples

4 shifting items menu 3 fixed items menu
Video 1 Video 2
4 items no background Tablet mode
4 items without changing background.
Menu show/hide feature is also disabled
Menu can be easily setup for (left or right) tablet support.
Video 3 Tablet Mode

Sizing

Dimensions and paddings follow the Google giudelines
Sizing

Tablets

The View supports tablet mode too (Left or Right). In order to enable tablet mode this is the configuration that should be used:

<it.sephiroth.android.library.bottomnavigation.BottomNavigation
    android:id="@+id/BottomNavigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="start"
    app:bbn_entries="@menu/bottombar_menu_3items"
    app:bbn_badgeProvider="@string/bbn_badgeProvider"
    app:layout_behavior="@string/bbn_tablet_view_behavior" />

Styling

The xml menu supports the following attributes in the <menu> tag:

<declare-styleable name="BottomNavigationMenu">
    <!-- menu default background color -->
    <attr name="android:background" />
    
    <!-- default badge color -->
    <attr name="bbn_badgeColor" format="color" />

    <!-- animation duration for the menu items -->
    <attr name="bbn_itemAnimationDuration" format="integer" />

    <!-- ripple selector color -->
    <attr name="bbn_rippleColor" format="color" />

    <!-- menu item active color -->
    <attr name="bbn_itemColorActive" format="color" />

    <!-- menu item inactive color -->
    <attr name="bbn_itemColorInactive" format="color" />

    <!-- menu item disabled color -->
    <attr name="bbn_itemColorDisabled" format="color" />

    <!-- force fixed behavior and always display item labels -->
    <!-- default implementation is false and the labels are -->
    <!-- shown only if there are less than 4 items in the menu -->
    <attr name="bbn_alwaysShowLabels" format="boolean" />
</declare-styleable>

Note: By default when there are 4 or 5 elements, only the selected item will display the label. In order to force all the items to always show their label, use bbn_alwaysShowLabels in the menu xml.

Badges

Badges

There's a basic support for badges using the default implementation. In order to display a badge in the current BottomNavigation view, all you have to do is:

    final BadgeProvider provider = bottomNavigationView.getBadgeProvider();
    provider.show(R.id.bbn_item3);

This code will show a little circle badge on the menu item with the id "bbn_item3".
You can define the default badge color inside the menu xml itself:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:bbn_badgeColor="#FFFF0000">
    
    <item
        android:id="@+id/bbn_item1"
        android:color="@color/colorPrimary"
        android:icon="@drawable/ic_cloud_off_white_24dp"
        android:title="Cloud Sync" />
        
    ...
</menu>

Then you can hide the badge using:

    bottomNavigation.getBadgeProvider().remove(R.id.bbn_item3);

Badges Customization

You can use your own Drawable by extending the BadgeProvider class. Once you've setup your new class you can tell the BottomNavigation view to use your class by specifying it in the "bbn_badgeProvider" attribute of your xml file.
For instance:

<it.sephiroth.android.library.bottomnavigation.BottomNavigation
    android:id="@id/BottomNavigation"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    app:bbn_badgeProvider="my.custom.BadgeProviderCustom"
    app:bbn_entries="@menu/bottombar_menu_4items"
    app:layout_behavior="@string/bbn_phone_view_behavior" />

This will make your my.custom.BadgeProviderCustom the default BadgeProvider.

License

The MIT License (MIT)

Copyright (c) 2016 Alessandro Crugnola

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.

More Repositories

1

ImageViewZoom

Android ImageView widget with zoom and pan capabilities
Java
1,893
star
2

android-target-tooltip

Create Toast like tooltips, but targets can be specified, plus custom properties and features
Kotlin
1,467
star
3

HorizontalVariableListView

Horizontal list view for Android which allows variable items widths
Java
859
star
4

AndroidWheel

Custom wheel widget for android
Java
385
star
5

NumberSlidingPicker

Android Number Picker with gestures
Kotlin
352
star
6

ViewRevealAnimator

ViewAnimator view with a lollipop style reveal effect
Java
338
star
7

android-floating-action-menu

Floating Action Menu for Android. Inspired by the Google Plus floating menu
Java
239
star
8

purePDF

A complete actionscript PDF library
ActionScript
141
star
9

AndroidUIGestureRecognizer

AndroidGestureRecognizer is an Android implementation of the Apple's UIGestureRecognizer framework
Kotlin
134
star
10

Android-Exif-Extended

Exif extended library for Android, based on jhead c library (http://www.sentex.net/~mwandel/jhead/)
Java
134
star
11

OverlayMenu

Android Overlay Menu
Java
120
star
12

Android-Easing

Ligh weight android easing
Java
105
star
13

RangeSeekBar

A Range Slider for Android.
Java
99
star
14

Tri-State-Checkbox

3 State Checkbox for android in pure Material Style
Java
59
star
15

RxBroadcast

Reactive Broadcast for Android
Java
12
star
16

ABTest

Simple library for ab testing in android
Java
11
star
17

vignette_demo

Simple demo on how to create a "Vignette" effect in Android
Java
10
star
18

SubtleRater

Discreet AppRater for Android
Java
10
star
19

HListViewAnimations

Based on ListViewAnimations, but target to the HListView instead
Java
10
star
20

Android-MultiSharing

Example on how to do multiple sharing in Android
Java
9
star
21

Appunti

Source code for the Note app available at https://play.google.com/store/apps/details?id=it.sephiroth.android.app.appunti
Kotlin
8
star
22

AlertDialogCustomStyleDemo

Demonstrate how to effectively customize the Android AlertDialog
Java
8
star
23

SBB-Tactile

SBB Tactile Demo App
Kotlin
7
star
24

TwitterAndroidSDK

Twitter SDK for Android, using Twitter4j
Java
7
star
25

python-adb-client

Pure python adb client
Python
5
star
26

android-disk-multi-cache

Multi Cache purpose based on DiskLruCache
Java
5
star
27

radb_client

adb client written in rust
Rust
4
star
28

DiskLruImageCache

Simple file based image cache
Java
4
star
29

ascii_generator

simple python script to print and convert images to ascii art
Python
4
star
30

material_drawable

Provides material background drawables to views
Kotlin
4
star
31

go_adb_client

Go adb client
Go
3
star
32

SimpleLogger

Simple Android logger
Java
2
star
33

git-owners

Simple python utility to generate a report about owners of files inside a git repository
Python
2
star
34

SimpleLruCache

Simple LruCache
Kotlin
2
star
35

kotlin_extensions

Misc Kotlin Extensions for Android
Kotlin
2
star
36

lollipop-transitions

Generic Transitions to be used with the Android 5.0 Transition Framework
1
star
37

Intellij-Settings

1
star
38

AndroidStudio-Settings

Java
1
star
39

JavaCheckStyle

java checkstyle
1
star