Coder Social home page Coder Social logo

roughike / bottombar Goto Github PK

View Code? Open in Web Editor NEW
8.4K 239.0 1.5K 39.86 MB

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

License: Apache License 2.0

Java 100.00%
android material-design bottom-navigation library java

bottombar's Introduction

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.

bottombar's People

Contributors

alorma avatar amenon avatar ashok-varma avatar benoitletondor avatar bowyer-app avatar brianhama avatar celanajaya avatar dptsolutions avatar ened avatar henhal avatar hyl avatar jlelse avatar leonardo2204 avatar mik-dass avatar mikecole20 avatar ncapdevi avatar ngoa avatar nikoladespotoski avatar pocheshire avatar prototypez avatar ravidsrk avatar roughike avatar servus7 avatar stephentuso avatar swordfish90 avatar westlinkin avatar xizzhu avatar xklakoux avatar xvarlez avatar yombunker 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  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

bottombar's Issues

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?

NullPointerException occurred when i did not set mapColor.

ver1.0.5

i did not set "mapColorForTab()" method.

(mColorMap is null)

java.lang.NullPointerException
at com.roughike.bottombar.BottomBar.handleBackgroundColorChange(BottomBar.java:545)
at com.roughike.bottombar.BottomBar.selectTab(BottomBar.java:530)
at com.roughike.bottombar.BottomBar.onClick(BottomBar.java:366)
at android.view.View.performClick(View.java:4492)
at android.view.View$PerformClick.run(View.java:18647)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)

thank you.

Remove attributes from manifest's Application

A library shouldn't declare unnecessary attributes on the Application as doing so will automatically merge them into app's manifest. For example, an app that doesn't declare supportsRtl will now have it set to true after importing this library, even though the default value should be false.

BottomBar/bottom-bar/src/main/AndroidManifest.xml

<application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:supportsRtl="true">

</application>

Does not detect whether device have soft navigation bar or not

If no detect whether android device have soft navigation bar or not then the height of bottom bar will abnormal.
Modification:
BottomBar.java
navBarMagic() {
...
boolean hasMenuKey = ViewConfiguration.get(activity).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
final int navBarHeight;

        if(!hasMenuKey && !hasBackKey) {
          if (navBarIdentifier > 0) {
            navBarHeight = res.getDimensionPixelSize(navBarIdentifier);
          } else {
            navBarHeight = MiscUtils.dpToPixel(activity, 48);
          }
        } else {
          navBarHeight = 0;
        }

...
}

Licenses inside the project

Why the licenses are inside of the folders of the library? It would be better to use one file in the root of the library.

will you release a gradle?

will you release a gradle?
and is this library have been finished for stable use? do you still have some import feature to add or modify?

Thank you for your great job~
Best Wishes~

Three icons BottomBar background color

Hi, that's mentioned earlier in other issues, but i open a new one just to discuss it.

Material design specs doesn't cover the light with light problem:

It will be great if we can set a color for the BottomBar at anytime, and also will be cool to have a custom attribute to set it via theme.

If you want i can open a PR for it

Library structure

Hi,

First nice job doing this library, but there are few things I would change.

  1. Make it more flexible, I do not see the reason why to create the bar dynamically in java. This is a ui library, thus should be provided as xml widget. Why? well, it makes it dynamic, flexible and visually to have it on the xml, the dev will be able to decide if wants to have some other view on top, for example coordinator layout? what happen here with the scroll behavior? etc...
  2. I would keep it simple! I don't see the reason why the BottomBar should be handling fragments. It should only be responsible of creating the tabs and the proper animations for each item as well as notifying on event. That's the problem of some UI libraries, they try to do too much.
  3. Related to the first point. Create and style_attribute so the dev can set a menu from xml.
  4. Add ability to set the full color of the BottomBar by tab, so a tab should define, icon, text, color

If I have so time this weekend I maybe fork it and make some pull request.

Br,
Marcel

Not detecting software navbar on CM11

I'm running Cyanogenmod 12 (Android 5.1.1) on my OnePlus One and I when I went for a trial run I noticed that the library always detects the software navbar as being active. It's possible to enable it and use it instead of the hardware buttons on the device, but by default it's not active.

It might be worth noting that I have configured my hardware menu button as recent apps but as far as I've noticed no changes when I configure it as menu button.

screenshot_2016-03-20-15-51-48
screenshot_2016-03-20-15-52-00

Weird navigation behavior

Not sure if it's just me.. but I have 5 menu items.. I can't seem to get back to home (0).

I can click and go through all the others fine but clicking home doesn't work. except on the one activity which I have: mBottomBar.selectTabAtPosition(2, false); set in the onResume.. and that ONLY works if I go to menu item 2 then 3, hit return, and then click on 0.

If I click on item 2, then back to home it doesn't work.

RecyclerView inside FrameLayout doesen't work

Hello, I used the code below, the frame layout have recyclerview, but it doesn't show with BottomBar, only recyclerview or bottombar not both..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bb_bottom_bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white" />
    <FrameLayout
        android:id="@+id/fragmentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

error when switch from 1.0.1 to 1.0.3

using 1.0.1, my app runs well, except the ugly top border.
after switch to 1.0.3, and add the statement:mBottomBar.hideShadow(), just like below:
mBottomBar = BottomBar.attach(this, savedInstanceState); mBottomBar.hideShadow(); mBottomBar.setItemsFromMenu(R.menu.menu_bottombar, new OnMenuTabSelectedListener() { @Override public void onMenuItemSelected(int resId) { switch (resId) { case R.id.bottomBarHome: displayView(0); break;
the ugly top border appear above the toolbar:
before:
2016-03-18 12 23 49
after:
2016-03-18 12 22 33

next, when click the bottom icon, error occurs:
2016-03-18 12 31 33

the code have been posted in the issue:
How to style top border? #3

Bottom Bar overlays part of the layout

After the latest update, the bottom bar is taking up part of the bottom layout (see how the FAB is overlapped), I guess because it isn't pushing it up?

screenshot_20160320-233349

Android Iconics

I'm using your BottomBar with another good lib to generate icons : Android Iconics. Its implementation is so easy, you can maybe refer a link into the readme for people who want ? Or don't knoa about that lib ?
https://github.com/mikepenz/Android-Iconics
quick showcase :

bottomBar = BottomBar.attach(view, savedInstanceState);
        bottomBar.setFragmentItems(getActivity().getSupportFragmentManager(), R.id.container,
                        new BottomBarFragment(new LatestKitFragment(), new IconicsDrawable(getActivity(), CommunityMaterial.Icon.cmd_trending_up).sizeDp(18), "Trending"),
                        new BottomBarFragment(new LatestKitFragment(), new IconicsDrawable(getActivity(), CommunityMaterial.Icon.cmd_newspaper).sizeDp(18), "Latest"),
                        new BottomBarFragment(new LatestKitFragment(), new IconicsDrawable(getActivity(), CommunityMaterial.Icon.cmd_tag_faces).sizeDp(18), "All")
        );

How to show all titles visible and set custom position ?

Hi. Thank you for your amazing lib!
I have a few questions, answer on which I didn't find at documentation.

  1. how can I make title always visible for all tabs? As on your first example animation on the readme.
  2. How can I create my activity with BottomBar wich will stay by default on the second position, for example?

Change typeface

Is it possible to change the typeface of the labels by a function like bottomBar.setTypeface(Typeface tf) ?

NoSuchMethodError

java.lang.NoSuchMethodError: android.widget.FrameLayout.
at com.roughike.bottombar.BottomBar.(BottomBar.java:86)
at com.roughike.bottombar.BottomBar.(BottomBar.java:72)
at com.roughike.bottombar.BottomBar.attach(BottomBar.java:131)
at com.example.bottombar.sample.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:4470)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
at android.app.ActivityThread.access$600(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method)

Dark mode doesn't seem to work

After enabling dark mode with useDarkTheme(true), the bottom bar looks exactly the same as before. Selecting a tab causes it to disappear (I'm guessing because the text is now white):

screenshot_20160319-202740

Snackbars should go above the bottom bar.

I don't know if it was already reported, but when I implement this library and try to attach a snack bar like so:

Snackbar.make(bottomBar, "Some text", Snackbar.LENGTH_LONG).show();

I get this result (The snackbar overlays the bottom bar).

According to the guidelines it should look like this.

And once again, thank you for this great and quick implementation.

Does not follow Material design specs

Hi, this was a fast release! I was just reading about this a couple of days ago.

I noticed that the second gif you posted does not follow the material design specs. The active & inactive items don't shrink or expand.

Crashed when fast switch item

17:58:20.335 8390-8390/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.bottombar.sample, PID: 8390
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.view.ViewGroup.getContext()' on a null object reference
at com.example.bottombar.sample.SampleFragment.onCreateView(SampleFragment.java:50)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5477)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
03-18 17:58:20.335 2825-3406/? W/ActivityManager: Force finishing activity 1 com.example.bottombar.sample/.MainActivity

How to set color of bottom bar and its items?

Hello, just started checking this out and it seems really cool. However I can't seem to find out how to set the background color or item selected color? Thanks and continue the great work!

can not understand the README

In Can it handle my Fragments and replace them automagically when a different tab is selected?, codes are:

mBottomBar.setFragmentItems(getSupportFragmentManager(), R.id.fragmentContainer,
    new BottomBarFragment(SampleFragment.newInstance("Content for recents."), R.drawable.ic_recents, "Recents"),
    new BottomBarFragment(SampleFragment.newInstance("Content for favorites."), R.drawable.ic_favorites, "Favorites"),
    new BottomBarFragment(SampleFragment.newInstance("Content for nearby stuff."), R.drawable.ic_nearby, "Nearby")
);

But in Separate BottomBars for individual Fragments, they are:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)     {
    View view = inflater.inflate(R.layout.my_fragment_layout, container, false);
    // initialize your views here

    BottomBar bottomBar = BottomBar.attach(view, savedInstanceState);
    bottomBar.setItems(
        new BottomBarTab(R.drawable.ic_recents, "Recents"),
        new BottomBarTab(R.drawable.ic_favorites, "Favorites"),
        new BottomBarTab(R.drawable.ic_nearby, "Nearby")
    );

    // Important! Don't return the view here. Instead, return the bottomBar, as it already contains your view.
    return bottomBar;
}

So if I wanna use Bottom bars connected with 4 different fragments, what should I use?

BTW, you guys are really fast for this repository.

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.