(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.

Overview

BottomBar (Deprecated)

I don't have time to maintain this anymore. I basically wrote the whole library in a rush, without tests, while being a serious expert beginner at the time. As a result, there's a lot of unpredictable moving parts and the tests probably aren't that great either. Don't really know, since I haven't touched this in ages.

I'd recommend you to use the official BottomNavigationView from Google and urge them to implement the features you need. Or use another 3rd party library.

Build Status Coverage Status Download

Version 2.0 released!

The latest version before that can be found in the v1 branch

  • Cleaner code and better APIs
  • No more unnecessary stuff or spaghetti mess
  • Now the look, feel and behavior is defined in XML, as it should be
  • No more nasty regressions, thanks to the automated tests
  • Everything is a little different compared to earlier, but it's for the greater good!

How to contribute

Changelog

What?

A custom view component that mimics the new Material Design Bottom Navigation pattern.

Does it work on my Grandpa Gary's HTC Dream?

Nope. The minSDK version is API level 11 (Honeycomb).

Gimme that Gradle sweetness, pls?

compile 'com.roughike:bottom-bar:2.3.1'

Maven:

<dependency>
  <groupId>com.roughike</groupId>
  <artifactId>bottom-bar</artifactId>
  <version>2.3.1</version>
  <type>pom</type>
</dependency>

How?

You can add items by writing a XML resource file.

Creating the icons

The icons must be fully opaque, solid black color, 24dp and with no padding. For example, with Android Asset Studio Generic Icon generator, select "TRIM" and make sure the padding is 0dp. Here's what your icons should look like:

Sample icons

Adding items from XML resource

Define your tabs in an XML resource file.

res/xml/bottombar_tabs.xml:

<tabs>
    <tab
        id="@+id/tab_favorites"
        icon="@drawable/ic_favorites"
        title="Favorites" />
    <tab
        id="@+id/tab_nearby"
        icon="@drawable/ic_nearby"
        title="Nearby" />
    <tab
        id="@+id/tab_friends"
        icon="@drawable/ic_friends"
        title="Friends" />
</tabs>

Then, add the BottomBar to your layout and give it a resource id for your tabs xml file.

layout/activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <!-- This could be your fragment container, or something -->
    <FrameLayout
        android:id="@+id/contentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottomBar" />

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        app:bb_tabXmlResource="@xml/bottombar_tabs" />

</RelativeLayout>

Setting up listeners

By default, the tabs don't do anything unless you listen for selection events and do something when the tabs are selected.

MainActivity.java:

public class MainActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
        bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelected(@IdRes int tabId) {
                if (tabId == R.id.tab_favorites) {
                    // The tab with id R.id.tab_favorites was selected,
                    // change your content accordingly.
                }
            }
        });
    }
}

If you want to listen for reselection events, here's how you do it:

bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
    @Override
    public void onTabReSelected(@IdRes int tabId) {
        if (tabId == R.id.tab_favorites) {
            // The tab with id R.id.tab_favorites was reselected,
            // change your content accordingly.
        }
    }
});

Intercepting tab selections

If you want to conditionally cancel selection of any tab, you absolutely can. Just assign a TabSelectionInterceptor to the BottomBar, and return true from the shouldInterceptTabSelection() method.

bottomBar.setTabSelectionInterceptor(new TabSelectionInterceptor() {
    @Override
    public boolean shouldInterceptTabSelection(@IdRes int oldTabId, @IdRes int newTabId) {
        if (newTabId == R.id.tab_pro_feature && !userHasProVersion()) {
          startProVersionPurchaseFlow();
          return true;
        }
        
        return false;
    }
});

Changing icons based on selection state

If you want to have different icon when a specific tab is selected, just use state list drawables.

res/drawable/my_tab_icon.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_myicon_selected" android:state_selected="true" />
    <item android:drawable="@drawable/ic_myicon_default" android:state_selected="false" />
</selector>

res/xml/bottombar_tabs.xml

...
<tab
    id="@+id/tab_favorites"
    icon="@drawable/my_tab_icon"
    title="Favorites" />
<!-- You can use @color resources too! -->
...

Those color changing tabs look dope. Howdoidodat?

Just add barColorWhenSelected to each tab. When that tab is selected, the whole BottomBar background color is changed with a nice animation.

res/xml/bottombar_tabs.xml

<tabs>
    <tab
        id="@+id/tab_favorites"
        icon="@drawable/ic_favorites"
        title="Favorites"
        barColorWhenSelected="#5D4037" />
    <!-- You can use @color resources too! -->
</tabs>

How do I draw it under the navbar?

First, define a style that is a child of your main application theme:

res/values-v21/styles.xml

<style name="AppTheme.TransNav" parent="AppTheme">
    <item name="android:navigationBarColor">@android:color/transparent</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

You'll also have to make a stub version of the same theme to avoid crashes in previous API levels than Lollipop:

res/values/styles.xml

<style name="AppTheme.TransNav" parent="AppTheme" />

Also include the same stub in your values-land-v21.xml to avoid transparent navbar and weird behavior on landscape.

res/values-land-v21.xml:

<style name="AppTheme.TransNav" parent="AppTheme" />

Apply the theme in AndroidManifest.xml for your Activity.

AndroidManifest.xml:

<activity android:name=".MyAwesomeActivity" android:theme="@style/AppTheme.TransNav" />

Finally, set bb_behavior to include the underNavbar flag and you're good to go!

activity_my_awesome.xml:

<com.roughike.bottombar.BottomBar
    android:id="@+id/bottomBar"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:layout_alignParentBottom="true"
    app:bb_tabXmlResource="@xml/my_awesome_bottombar_tabs"
    app:bb_behavior="underNavbar" />

What about Tablets?

Specify a different layout for your activity in res/layout-sw600dp folder and set bb_tabletMode to true.

res/layout-sw600dp/activity_main.xml:

<RelativeLayout
    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">

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        app:bb_tabXmlResource="@xml/bottombar_tabs_three"
        app:bb_tabletMode="true" />

    <!-- This could be your fragment container, or something -->
    <FrameLayout
        android:id="@+id/contentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toRightOf="@+id/bottomBar" />

</RelativeLayout>

How do I hide it automatically on scroll?

Easy-peasy!

activity_main.xml:

<android.support.design.widget.CoordinatorLayout 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.support.v4.widget.NestedScrollView
        android:id="@+id/myScrollingContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- Your loooooong scrolling content here. -->

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

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_gravity="bottom"
        app:bb_tabXmlResource="@xml/bottombar_tabs_three"
        app:bb_behavior="shy"/>

</android.support.design.widget.CoordinatorLayout>

Badges

You can easily add badges for showing an unread message count or new items / whatever you like.

BottomBarTab nearby = bottomBar.getTabWithId(R.id.tab_nearby);
nearby.setBadgeCount(5);

// Remove the badge when you're done with it.
nearby.removeBadge/();

All customization options

For the BottomBar

<com.roughike.bottombar.BottomBar
    android:id="@+id/bottomBar"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    app:bb_tabXmlResource="@xml/bottombar_tabs_three"
    app:bb_tabletMode="true"
    app:bb_behavior="shifting|shy|underNavbar"
    app:bb_inActiveTabAlpha="0.6"
    app:bb_activeTabAlpha="1"
    app:bb_inActiveTabColor="#222222"
    app:bb_activeTabColor="@color/colorPrimary"
    app:bb_badgesHideWhenActive="true"
    app:bb_titleTextAppearance="@style/MyTextAppearance"
    app:bb_titleTypeFace="fonts/MySuperDuperFont.ttf"
    app:bb_showShadow="true" />
bb_tabXmlResource
the XML Resource id for your tabs, that reside in values/xml/
bb_tabletMode
if you want the BottomBar to behave differently for tablets. There's an example of this in the sample project!
bb_behavior
shifting: the selected tab is wider than the rest. shy: put the BottomBar inside a CoordinatorLayout and it'll automatically hide on scroll! underNavbar: draw the BottomBar under the navBar!
bb_inActiveTabAlpha
the alpha value for inactive tabs, that's used in the tab icons and titles.
bb_activeTabAlpha
the alpha value for active tabs, that's used in the tab icons and titles.
bb_inActiveTabColor
the color for inactive tabs, that's used in the tab icons and titles.
bb_activeTabColor
the color for active tabs, that's used in the tab icons and titles.
bb_badgeBackgroundColor
the background color for any Badges in this BottomBar.
bb_badgesHideWhenActive
whether badges should be hidden for active tabs, defaults to true.
bb_titleTextAppearance
custom textAppearance for the titles
bb_titleTypeFace
path for your custom font file, such as fonts/MySuperDuperFont.ttf. In that case your font path would look like src/main/assets/fonts/MySuperDuperFont.ttf, but you only need to provide fonts/MySuperDuperFont.ttf, as the asset folder will be auto-filled for you.
bb_showShadow
controls whether the shadow is shown or hidden, defaults to true.

For the tabs

<tab
    id="@+id/tab_recents"
    title="Recents"
    icon="@drawable/empty_icon"
    inActiveColor="#00FF00"
    activeColor="#FF0000"
    barColorWhenSelected="#FF0000"
    badgeBackgroundColor="#FF0000"
    badgeHidesWhenActive="true" />
inActiveColor
the color for inactive tabs, that's used in the tab icons and titles.
activeColor
the color for active tabs, that's used in the tab icons and titles.
barColorWhenSelected
the color that the whole BottomBar should be when selected this tab.
badgeBackgroundColor
the background color for any Badges in this tab.
badgeHidesWhenActive
whether or not the badge should be hidden when this tab is selected, defaults to true.

Apps using BottomBar

  • Nearby : A location-based social networking app with over 5 million users.
  • FragNav : An Android Library for managing multiple stacks of Fragments. BottomBar is used in the sample app.
  • BottomNavigationBar : BottomBar ported to C# for Xamarin developers
  • KyudoScoreBookTeam : BottomBar is used in the KyudoScoreBookTeam app.
  • memeham : BottomBar is used in the memeham app.
  • NewsCatchr : A newsreader app, which uses this BottomBar library.
  • GitSkarios : A Github android App, to visit your repositories, gists and more!

Send me a pull request with modified README.md to get a shoutout!

Contributions

Feel free to create issues and pull requests.

When creating pull requests, more is more: I'd like to see ten small pull requests separated by feature rather than all those combined into a huge one.

License

BottomBar library for Android
Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Bottom bar falls to low behind the navigation bar

    Bottom bar falls to low behind the navigation bar

    I'm sure I did something wrong but I can't figure out what.

    I have this XML:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/main_coordinator_layout"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context=".app.MainActivity">
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="true"
            android:fitsSystemWindows="true">
    ...
        </android.support.design.widget.AppBarLayout>
    
        <FrameLayout
            android:id="@+id/main_fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    
        <android.support.design.widget.FloatingActionButton ... />
    
    </android.support.design.widget.CoordinatorLayout>
    

    This is the code I use:

    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_coordinator_layout);
    mBottomBar = BottomBar.attachShy(coordinatorLayout, findViewById(R.id.main_fragment_container), savedInstanceState);
    final OnMenuTabClickListener listener = new OnMenuTabClickListener() {
        @Override
        public void onMenuTabSelected(@IdRes int menuItemId) {
            displayFragment(menuItemId, null);
        }
    
        @Override
        public void onMenuTabReSelected(@IdRes int menuItemId) {
            // The user reselected item number one, scroll your content to top.
        }
    };
    mBottomBar.setItemsFromMenu(R.menu.bottom_tab_bar, listener);
    
    mBottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.colorAccent));
    mBottomBar.mapColorForTab(1, 0xFF5D4037);
    mBottomBar.mapColorForTab(2, "#7B1FA2");
    mBottomBar.mapColorForTab(3, "#FF5252");
    

    This is the result I get:

    result screenshot

    I have tried all combinations of noTopOffset, noNavBarGoodness, fitsSystemWindows... I can't get the bottom bar to be:

    • shy
    • over the transparent navigation bar

    Note that this has been taken with a Nexus 5X running N.

    opened by BenoitDuffez 33
  • How to implement the navigation bar goodness?

    How to implement the navigation bar goodness?

    I want to get this result.

    Here is my current code:

    
           bottomBar = BottomBar.attach(this, savedInstanceState);
    
            bottomBar.setItemsFromMenu(R.menu.bar, new OnMenuTabSelectedListener() {
                @Override
                public void onMenuItemSelected(int resId) {
    
                }
            });
            bottomBar.mapColorForTab(0, ContextCompat.getColor(this, R.color.primary_dark));
            bottomBar.mapColorForTab(1, ContextCompat.getColor(this, R.color.md_teal_600));
            bottomBar.mapColorForTab(2, ContextCompat.getColor(this, R.color.md_red_500));
            bottomBar.mapColorForTab(3, ContextCompat.getColor(this, R.color.md_blue_grey_500));
    

    But the result of this code is a black navbar.

    What am I missing?

    help wanted 
    opened by rosenpin 33
  • Shadow related issue when used in combination with MaterialDrawer

    Shadow related issue when used in combination with MaterialDrawer

    I'm working on an app where there's both a drawer and a bottom menu for navigation. The bottom navigation only has 4 items (8 for tablets) at most, while the drawer has all the remaining navigation items. If there's more than X items (4 or 8), the bottom navigation is never initialized and there'll only be a drawer menu.

    For the drawer I'm using this library by @mikepenz: https://github.com/mikepenz/MaterialDrawer.

    There seems to be an issue when opening the drawer on a device with API > 15 (works on 15), the fragment that disappears behind the opening drawer doesn't properly get 'shadowed' (not sure how to explain what happens). Instead, the elements and toolbar and all that are staying the same color while the background of the fragment will properly turn to a darker color. Disabling the bottom navigation bar solves this issue.

    A few screenshots to explain what I'm talking about:

    Here's a Moto G running API 22. The bottom navigation is disabled here: http://i.imgur.com/8ih0m9p.png

    Here's the same phone with the bottom navigation enabled: http://i.imgur.com/lddg7P5.png

    So in the first screenshot you can see that the drawer works as expected. Enabling the bottom navigation somehow breaks this.

    This issue also exists on my Samsung Tab A running API 21. This issue does not exist on my HTC Incredible A running API 15.

    I understand this is not of great concern here at all considering I'm using two 3rd party libs in combination with each other that are not meant to be used at the same time (or at least not designed to). Any advise is therefore appreciated. :smile:

    opened by jasperrietrae 31
  • Defining two bottom bar layouts with different number of items

    Defining two bottom bar layouts with different number of items

    I recently saw the request "Fixed setting items programatically #512" that made it possible to define a layout after the initialization of the bottombar.

    So I defined two separate layouts, one bottom bar layout for a DEBUG-mode including 5 items, and one for USER-mode including 4 items.

    The first switch between the two different layouts went fine, but when switching back to the USER mode layout again, the items just adds up to the prior layout so that the total items becoms 9 instead of 4. See code below:

    switch(layoutMode){
            case Constants.DEBUG_MODE:
                bottomBar= new BottomBar(getApplicationContext(),null);
                bottomBar = (BottomBar) findViewById(R.id.bottomBar_debug);
                bottomBar.setItems(R.xml.bottom_menu_debug);
                break;
            case Constants.USER_MODE:
                bottomBar =  new BottomBar(getApplicationContext(),null);
                bottomBar= (BottomBar) findViewById(R.id.bottomBar);
                bottomBar.setItems(R.xml.bottom_menu);
                break;
        }
    
    opened by mysqo 21
  • getBarSize(new OnSizeDeterminedListener()) does not update (attachShy)

    getBarSize(new OnSizeDeterminedListener()) does not update (attachShy)

    This only give me one number, when my activity is first launched:

    bottomBar.getBarSize(new OnSizeDeterminedListener() { @Override public void onSizeReady(int size) { Log.e("height", String.valueOf(size)); float translationY = Math.min(0, floatingActionButton.getTranslationY() - size); floatingActionButton.setTranslationY(translationY); } });

    opened by alvarlagerlof 20
  • Non-highlighted title text is cut off

    Non-highlighted title text is cut off

    Hi,

    I have noticed that the bottom part of the title text is cut off. However, for some reason that doesn't seem to be a problem for the first tab, but only for the 2nd and 3rd (only tested with 3 tabs). You can see the problem in the sample app as well.

    Steps to reproduce:

    1. Start BottomBar sample app.
    2. Choose "SIMPLE EXAMPLE WITH THREE TABS"
    3. Observe the 2nd tab

    Actual behavior: The "y" is cut off (but only in the non-highlighted state).

    Expected behavior: Text shouldn't be cut off.

    bottombar text cut off

    Let me know if you need more input.

    Kevin

    bug v2 
    opened by kevinschlieper 15
  • Adding OnTabShouldSelectListener

    Adding OnTabShouldSelectListener

    Adding a way to intercept tab selection.

    EDIT

    I've added an interface OnTabShouldSelectListener with a single method boolean onTabShouldSelect(@IdRes int oldTabId, @IdRes int newTabId). The purpose of this is to be able to add logic to stop tab changes. There may be a better name for this interface and/or method. The BottomBar checks in private void handleClick(View v) for a non-null onTabShouldSelectListener and calls out to it to see if it should proceed with the tab change. This technically intercepts both select and reselect. I could also break the interface into two different methods, or rename the interface to something more encompassing.

    Our use case is that we want to warn the user of unsaved changes before they go (and then programmatically proceed with the tab change if they want to discard their unsaved changes).

    opened by mikecole20 13
  • Tabs text gets cut off for unselected tabs

    Tabs text gets cut off for unselected tabs

    I have integrated BottomBar. The issue I am having is that the tabs text gets cut off from bottom for unselected tabs.Below is the code I am using.How can i resolve it?

    ... <com.roughike.bottombar.BottomBar android:id="@+id/bottomBar" android:layout_width="match_parent" android:layout_height="@dimen/dp70" android:layout_alignParentBottom="true" app:bb_tabXmlResource="@xml/bottombar_tabs" /> bottombar_tabs.xml

    opened by bkjbkjbnkj687698698 13
  • `IllegalArgumentException: Wrong state class` when call `Activity.recreate()`

    `IllegalArgumentException: Wrong state class` when call `Activity.recreate()`

    Caused by: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.os.Bundle instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/bottomBarFlux. Make sure other views do not use the same id. at android.view.View.onRestoreInstanceState(View.java:15659) at com.roughike.bottombar.BottomBarTab.onRestoreInstanceState(BottomBarTab.java:453)

    bug v2 
    opened by Kevinrob 13
  • Empty Space above bar

    Empty Space above bar

    weirdbar

    There is an empty space above the bar, I am sorry if I missed something. I searched some of the open and closed tickets and didn't see anything.

    I have tried attaching using mBottomBar = BottomBar.attach(this, savedInstanceState); and mBottomBar = BottomBar.attach(findViewById(R.id.myCoordinator), savedInstanceState); but it still happens.

    Tested on Nexus 6p running N and Nexus 7 running 6.0.1

    Thanks,

    Jake

    help wanted 
    opened by DevJCrystal 13
  • Transparent navbar doesn't work when colors are not set (attachShy)

    Transparent navbar doesn't work when colors are not set (attachShy)

    I have three items in my bottombar, and i have a transparent navbar. The problem is that the bottombar needs to be moved up above the navbar. I want the scrolling to be the same as if it where colored.

    Sorry for my terrible English.

    Opened: screenshot mar 30 2016 11_43_38

    Closed: screenshot mar 30 2016 11_42_08

    enhancement 
    opened by alvarlagerlof 13
  • open third tab onstart

    open third tab onstart

    Assume I have five items in my menu. So I just want to open third tab on starting of the app. Currently it actually starts the first tab. So how to get third tab to be opened onstart?

    opened by rajesh-codes 3
  • Shy behaviour is not working

    Shy behaviour is not working

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="13dp" tools:context=".fragment.WorkspaceActivity">

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/navigation"
        android:animateLayoutChanges="true"
    
        >
    
    </FrameLayout>
    
    
    
        <com.roughike.bottombar.BottomBar
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_gravity="bottom"
            app:bb_behavior="shy"
            app:bb_tabXmlResource="@xml/bottombar_tabs"
            app:bb_tabletMode="false" />
    

    </android.support.design.widget.CoordinatorLayout>

    This is xml layout.Bottiomtans are not hiding while i scroll listview.

    opened by swetaranipanda 0
  • Programmatically activate tab without firing events

    Programmatically activate tab without firing events

    Hi,

    I am trying to find a way to activate a tab without having the "onTabSelected" method fire up, otherwise I'll go into a neverending-loop. I tried to remove the onTabSelectedListener, but it is quite a dirty move to me. Since I think that this component is very-well designed, there must be a way to simply activate a different tab's icon somehwere :)

    Pls advice

    Thx

    Andrea

    opened by theFasta 0
  • Fix: wrong getCurrentTabPosition value when called from OnTabSelectLi…

    Fix: wrong getCurrentTabPosition value when called from OnTabSelectLi…

    …stener

    Fixes this:

    bottomBar.setOnTabSelectListener { tabResId ->
        bottomBar.getCurrentTabPosition() // wrong value - I get the previous one not the current one
    }
    
    opened by fentino 0
  • Crash: NullPointerException

    Crash: NullPointerException

    Hi,

    I meet a null pointer exception when I am using this library. Here is the failing stacktrace: 11-21 15:02:19.170 12985 12985 E AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.roughike.bottombar.BottomBar.resizeTabsToCorrectSizes(BottomBar.java:391) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.roughike.bottombar.BottomBar.onLayout(BottomBar.java:761) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.android.internal.policy.DecorView.onLayout(DecorView.java:755) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2429) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2149) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1306) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6579) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:683) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:619) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6316) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)

    It seems that you did not check whether the xml resource exists or not. If the tabXmlResource(line 195) does not really exist, line 148 will not be executed. Hence, currentTabs will be null. When the method onLayout(line 756) is triggered by android framework, it will invoke resizeTabsToCorrectSizes will a null argument. Therefore, a NullPointerException will be triggered in line 391.

    Cheers

    opened by duetdroid2018 0
Releases(V2.3.1)
  • V2.3.1(Apr 14, 2017)

  • v2.3.0(Apr 6, 2017)

    • #713: Ripple touch feedback for tabs!
    • #716: Bugfix for misbehaving shadow. No more weird white spaces above the bar!
    • #717: Support for tabs with icons only, without titles!
    • #722: Showing / hiding the BottomBar when on shy mode.
    • #714: Controlling whether Toasts of tab titles are shown when long pressing tabs.
    • #719: Fix for wrong size in tabs
    • #712: Data binding fixes.

    Thanks for @yombunker, @MarcRubio and @tushar-acharya for their contributions!

    Source code(tar.gz)
    Source code(zip)
    bottom-bar-2.3.0.aar(75.49 KB)
  • v2.2.0(Mar 26, 2017)

    • Ability to change icons when the tabs are selected, using drawable selectors
    • Overriding tab selections is now supported, by using TabSelectionInterceptor
    • Internal code quality improvements and small changes
    Source code(tar.gz)
    Source code(zip)
  • v2.1.2(Mar 22, 2017)

Owner
Iiro Krankka
Iiro Krankka
[Deprecated] Android Library that implements Snackbars (former known as Undobar) from Google's Material Design documentation.

UndoBar This lib is deprecated in favor of Google's Design Support Library which includes a Snackbar and is no longer being developed. Thanks for all

Kai Liao 577 Nov 25, 2022
A skeleton of google's appcompat android navigation drawer with material design.

Lollipop AppCompat Skeleton A skeleton of google's appcompat android navigation drawer with material design. Compatible to work on 4.0+ Based on Googl

Sachin Shinde 99 Nov 29, 2022
A pane that slides up from the bottom of an android view

Slide Up Pane ##Introduction This is a UI component that closely simulates the bottom UI component of the current Google Maps application, except boun

brian griffey 95 Feb 16, 2020
Create an header for com.google.android.material.navigation.NavigationView

Header View This is a view for NavigationView in android.support.design library Import At the moment the library is in my personal maven repo reposito

Raphaël Bussa 106 Nov 25, 2022
Android layout decorators : Injecting custom attributes in layout files, Using decorators to get rid of unnecessary class explosion with custom views

Decor Decor is a library that applies decorators to Android layout with additional attributes without the need to extend and create a custom View for

Mouna Cheikhna 304 Nov 25, 2022
A Material design Android pincode library. Supports Fingerprint.

LolliPin A Lollipop material design styled android pincode library (API 14+) To include in your project, add this to your build.gradle file: //Loll

Omada Health 1.6k Nov 25, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Dec 30, 2022
An implementation of tap targets from the Material Design guidelines for feature discovery.

TapTargetView An implementation of tap targets from Google's Material Design guidelines on feature discovery. Min SDK: 14 JavaDoc Installation TapTar

Keepsafe 5.2k Dec 30, 2022
An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.

MaterialScrollBar An Android library that brings the Material Design 5.1 scrollbar to pre-5.1 devices. Designed for Android's recyclerView. Video Imag

Turing Technologies (Wynne Plaga) 784 Nov 29, 2022
A library that provides an implementation of the banner widget from the Material design.

MaterialBanner A banner displays a prominent message and related optional actions. MaterialBanner is a library that provides an implementation of the

Sergey Ivanov 252 Nov 18, 2022
An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.

MaterialScrollBar An Android library that brings the Material Design 5.1 scrollbar to pre-5.1 devices. Designed for Android's recyclerView. Video Imag

Turing Technologies (Wynne Plaga) 784 Nov 29, 2022
Material Design tap target for Android. https://sjwall.github.io/MaterialTapTargetPrompt/

Material Tap Target Prompt A Tap Target implementation in Android based on Material Design Onboarding guidelines. For more information on tap targets

Sam Wall 1.5k Jan 4, 2023
Custom android music player view.

InteractivePlayerView Custom android music player view. Screen Check it on youtube Usage(XML) Define it in your xml file. <co.mobiwise.library.Intera

Mert Şimşek 744 Dec 25, 2022
A beautiful Android custom View that works similar to a range or seekbar. With animations.

ValueBar A beautiful Android custom View that works similar to a range or seekbar. Selection by gesture. With animations. Supporting API level 11+. De

Philipp Jahoda 147 Nov 20, 2022
An android custom view that displays a circle with a colored arc given a mark

MarkView An android custom view that displays a circle with a colored arc given a mark. Usage Add as a dependency compile 'com.github.xiprox.markv

İhsan Işık 200 Nov 25, 2022
This is a android custom view , like a scratch card effect!

ScratchView This is a android custom view , like a scratch card effect! Last Update 采纳DearZack童鞋的优化思路,把计算擦除面积比例的操作放在手指离开屏幕时,以降低对CPU的占用。 Articles Scrat

D_clock爱吃葱花 316 Nov 29, 2022
An Android custom view to display digits rendered as dots in a grid, with a style like a 1970s LED clock.

#DotMatrixView This is an Android library project providing a custom view that can display things on a grid of dots. When the displayed value changes,

Mark Roberts 48 Apr 21, 2022
a custom view that provides dragged and scaled

DragScaleCircleView A custom imageview that provides the circle window can be dragged and scaled, crop image. How does it look? Why? Sometimes need to

null 514 Dec 22, 2022
NumberPickerView - Custom Android View to provide a user friendly way of picking numbers. 🧪

?? Custom view for Android which provides a modern design and gestures for picking numbers in a user friendly way.

Mirkamal 6 Feb 16, 2022