Coder Social home page Coder Social logo

cybernhl / bottomnavigationlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nikoladespotoski/bottomnavigationlayout

0.0 2.0 0.0 12.81 MB

Bottom Navigation Layout that embraces bottom navigation section of Material Design guidelines

Home Page: https://medium.com/@nullthemall/bottom-navigation-take-2-2172551be54e#.ld058o5js

Java 100.00%

bottomnavigationlayout's Introduction

BottomNavigationLayout

Simple lightweight library that works out of the box implementing Bottom navigation component of Material Design guidelines

Three items

Shifting mode off with more than 3 items

[Shifting mode on with more than 3 items] (https://fat.gfycat.com/UnsteadyGrotesqueCoral.webm)

Tablet mode:

Usage

  1. Add jitpack.io to your project gradle:
allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
  1. Add this library to your module gradle dependencies:
 compile 'com.github.NikolaDespotoski:BottomNavigationLayout:0.4.+'
  1. In xml layout resource
<despotoski.nikola.github.com.bottomnavigationlayout.BottomTabLayout
  android:id="@+id/tabs"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_gravity="bottom"
  android:background="?attr/selectableItemBackgroundBorderless"
  app:inactive_item_text_color="@color/colorPrimary"
  app:active_item_color_filter="@android:color/holo_red_dark"
  app:bottom_tabs_menu="@menu/bottom_navigation_items"
  app:bottom_tabs_menu_parent_background_colors="@array/menu_background_colors"/>
  1. Programatically:
 BottomTabLayout tabLayout = (BottomTabLayout) findViewById(R.id.tabs);
        tabLayout.setOnNavigationItemSelectionListener(this);
        tabLayout.setShiftingMode(true);
        tabLayout.setActiveItemColorResource(R.color.active_color);
        BottomTabLayout.BottomTabsBuilder builder = new BottomTabLayout.BottomTabsBuilder();
        builder.addBottomNavigationItem(
                new BottomNavigationItemBuilder()
                        .setText("Text 1")
                        .setIcon(R.drawable.ic_android_white_24dp)
                        .setParentColorBackground(android.R.color.holo_blue_bright)
                        .build());

        builder.addBottomNavigationItem(
                new BottomNavigationItemBuilder()
                        .setText("Item 2")
                        .setIcon(R.drawable.ic_favorite_white_24dp)
                        .setParentColorBackground(android.R.color.holo_orange_light)
                        .build());
        builder.addBottomNavigationItem(
                new BottomNavigationItemBuilder().setText("Item 3")
                        .setIcon(R.drawable.ic_favorite_white_24dp)
                        .setParentColorBackground(android.R.color.holo_blue_dark)
                        .build());
        builder.addBottomNavigationItem(
                new BottomNavigationItemBuilder()
                        .setText("Item 4")
                        .setIcon(R.drawable.ic_place_white_24dp)
                        .setParentColorBackground(android.R.color.holo_blue_bright)
                        .build());
        builder.addBottomNavigationItem(
                new BottomNavigationItemBuilder()
                        .setText("Item 5")
                        .setIcon(R.drawable.ic_favorite_white_24dp)
                        .setParentColorBackground(android.R.color.holo_green_light)
                        .build());
        tabLayout.populateBottomTabItems(builder);
  1. Tablet mode

In order to offset the content from BottomNavigatonLayout direct child of the CoordinatorLayout must use the provided tablet behavior like:

  <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        app:layout_behavior="@string/bottom_bar_tablet_behavior"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

        </FrameLayout>
    </android.support.v4.widget.NestedScrollView>
    

Use with FloatingActionButton

You must provide @string/bottom_bar_fab_behavior as behavior for your FAB:

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_marginRight="16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|bottom"
        android:layout_marginBottom="16dp"
        android:src="@drawable/ic_android_white_24dp"
        app:borderWidth="0dp"
        app:layout_behavior="@string/bottom_bar_fab_behavior"
        app:rippleColor="#ffffff" />
        

#Notes

  1. Number of items must be between 3 and 5 according to Material Design Bottom Navigation Guidelines
  2. Shifting mode is on when the number of bottom items is greater than 3
  3. This library does not handle cross fade between top-level sections when item is clicked.
  4. Incomplete support to preHoneycomb.

If you spot any oddities please open an issue! Thanks!

bottomnavigationlayout's People

Contributors

nikoladespotoski avatar

Watchers

James Cloos avatar Neo avatar

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.