Bottombar: Snackbars should go above the bottom bar.

Created on 18 Mar 2016  路  10Comments  路  Source: roughike/BottomBar

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.

help wanted

All 10 comments

For this, the bottom bar needs to be inside a coordinator layout. I think that the library doesn't have to care about that because is coordinator layout work . Hope that this doesn't break some flexibility

I'm trying to resolve this. Seems a bit tricky so far.

If you're using bottomBar.attach(this, savedInstanceState), give the Snackbar the CoordinatorLayout as the first parameter.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myCoordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    ...

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

MainActivity.java

Snackbar.make(findViewById(R.id.myCoordinator), "Can you smell what The Rock is cooking?", Snackbar.LENGTH_LONG).show();

Works!

Awesome!

I used the co-ordinator layout as you said, but the snackbar never appeared
this.myCoordinator = (CoordinatorLayout) findViewById(R.id.myCoordinator);
this.bottomBar = (BottomBar) findViewById(R.id.bottomBar);
snackbar = Snackbar.make(myCoordinator, "This is a snackbar", Snackbar.LENGTH_INDEFINITE);
snackbar.show();

Am i doing something wrong here?

Hi @roughike, @rosenpin

I am using 2.1.1 version. Snackbar is not visible in anyway. How did you achieve this? Could you provide more detailed code, please? I could not find any method like BottomBar#attach()

That's my code:

Snackbar.make(coordinatorLayout, "message", Snackbar.LENGTH_LONG).show();
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activityHomeRoot"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <include layout="@layout/layout_cci_toolbar"/>

    <FrameLayout
        android:id="@+id/activityHomeFrameLayoutContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_marginBottom="@dimen/home_bottom_bar_height_without_shadow"/>

    <com.roughike.bottombar.BottomBar
        android:id="@+id/activityHomeBottomBar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/home_bottom_bar_height"
        android:layout_gravity="bottom"
        style="@style/CCIBottomBar"/>

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

    <style name="CCIBottomBar">
        <item name="bb_tabXmlResource">@xml/home_bottom_bar_tabs</item>
        <item name="bb_activeTabColor">@color/colorPrimary</item>
        <item name="bb_inActiveTabColor">@color/gunmetal</item>
    </style>

</resources>

@rosenpin Could you provide your working layout xml?

with below example It won't show at all (because its overlayed by the tabbar)

<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/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".mvp.navigation.NavigationActivity">

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="@color/bg_color" />

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomNavigation"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:bb_activeTabColor="@color/aqua"
        app:bb_inActiveTabColor="@color/grey_d_40"
        app:bb_showShadow="false"
        app:bb_tabXmlResource="@xml/bottom_navigation"
        app:layout_anchor="@id/container"
        app:layout_anchorGravity="bottom" />
</android.support.design.widget.CoordinatorLayout>

Maybe this is problem again in 2.X? Reopen maybe @roughike ?

EDIT:
Aparently switching to android.support.design.widget.BottomNavigationView doesn't change anything. Its support 25.2.0

@jkwiecien how are you displaying the SnackBar?

When I use android support library com.android.support:design:25.2.0,the snackbar won't work.is there any solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hiike picture Hiike  路  4Comments

tinybright picture tinybright  路  3Comments

Nolanus picture Nolanus  路  4Comments

zhangzhzh picture zhangzhzh  路  7Comments

LiuDeng picture LiuDeng  路  5Comments