How to show the diner above Bottombar?

I am using roughide BottomBar 2.0: https://github.com/roughike/BottomBar/

When I show the SnackBar, it displays on the very bottom bar.

I want it to be drawn over the BottomBar.

activity_main.xml:

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/here"
        android:background="#fff">

        <FrameLayout
            android:id="@+id/contentContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/bottomBar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Three Buttons Bar"
                android:id="@+id/textView"
                android:layout_centerVertical="true"
                android:layout_centerHorizontal="true"
                android:textColor="@color/colorPrimary"
                android:textSize="35sp" />

        </FrameLayout>

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

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

MainActivity.java:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(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(int tabId) {
                switch (tabId) {
                    case R.id.recent_item:
                        Snackbar.make(findViewById(R.id.main_activity), "Recent Item Selected", Snackbar.LENGTH_LONG).show();
                        break;
                    case R.id.favorite_item:
                        Snackbar.make(findViewById(R.id.main_activity), "Favorite Item Selected", Snackbar.LENGTH_LONG).show();
                        break;
                    case R.id.location_item:
                        Snackbar.make(findViewById(R.id.main_activity), "Location Item Selected", Snackbar.LENGTH_LONG).show();
                        break;
                }
            }
        });
    }
}

Screenshots:

BottomBar only BottomBar hidden when SnackBar appears

Is there something wrong with the layout file?
What am I missing?

I also checked this: Move the diner over the bottom panel , but that didn't help ..

EDIT:

I tried as Abtin said :

Snackbar.make(bottomBar, "Location Item Selected", Snackbar.LENGTH_LONG).show();

and

<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"
            app:bb_behavior="underNavbar"/>

Now it has become the following:

Bottom panel with extra space below This is a space filled by Snackbar.

As you can see, this is the unused space below the BottomBar when I set app:bb_behavior="underNavbar"what I don't want.

+4
5

CoordinatorLayout xml, , , SnackBar CoordinatorLayout View at fun. SnackBar.

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/viewSnack"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="50dp"/>

:

Snackbar.make(findViewById(R.id.viewSnack), "Text of the SnackBar", Snackbar.LENGTH_LONG).show();
+4

, .

Snackbar.make(findViewById(R.id.contentContainer), "Recent Item Selected", Snackbar.LENGTH_LONG).show();    
0

, , Snackbar.make().

Snackbar.make(bottomBar, "Location Item Selected", Snackbar.LENGTH_LONG).show();

, app:bb_behavior - .

0

Roughike BottomBar 2.0 Roughike BottomBar 1.4..

Now it works as intended (of course, the code changes).

I also tried AHBottomNavigation , it is cool and also works as intended.

I do not mark this as an β€œAnswer”, as it does not answer the question;)

0
source

With the new material design, Snackbars look new. You can display a snack bar above the BottomBar using this line:

Snackbar snackbar = Snackbar.make(parentView, text, duration);
snackbar.setAnchorView(bottomBar);

This will do the job.

0
source

Source: https://habr.com/ru/post/1658026/


All Articles