question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display Snackbar below android.support.v7.widget.Toolbar

See original GitHub issue

Is there a way to display the TSnackbar under the android Toolbar? Your sample code contains a coordinator layout, but I use a different activity main layout:

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

    <android.support.v7.widget.Toolbar
        android:id="@+id/tool_bar"
        style="@style/AppTheme.CustomToolbar"/>

    <FrameLayout
        android:id="@+id/fragment_placeholder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

fragment_placeholder is obviously a layout where I add fragments.

The problem is that it doesn’t matter what view I provide to TSnackbar.make, the snackbar always appears over my Toolbar, but below the notification panel (where the battery and other stuff is displayed, as you describe in the README). I want to display the snackbar below the Toolbar so it overlays a bit of “fragment_placeholder”, but nothing from “tool_bar”. I hope this is possible.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
nothingimportant55commented, Sep 28, 2016

I had the same issue, it was solved by simply wrapping my fragment layout in a coordinatorlayout. So, originally, my fragment layout top most view was a relative layout, I wrapped this in a coordinatorlayout and then attached the snackbar to the relativelayout, sorted. Good luck

0reactions
AndreiDcommented, Nov 2, 2016

I’ve updated the readme with the coordinatorlayout tip. Thanks for mentioning it

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Show a SnackBar on the top (below of the toolbar)
Show a SnackBar on the top (below of the toolbar) ... I'm trying to show a SnackBar on top below of the ToolBar...
Read more >
Android Snackbar Example Tutorial - DigitalOcean
A code snippet to display a basic android Snackbar is shown below. ... AppCompatActivity; import android.support.v7.widget.Toolbar ...
Read more >
Android Material Design and the Design Support Library
This tutorial gives an overview of Material Design UI components together with example code for using them in your application.
Read more >
Snackbars - Material Design
The Snackbar class provides static make methods to produce a snackbar configured in the desired way. These methods take a View, which will...
Read more >
Material Design with the Android Design Support Library
The library includes a navigation drawer view, floating labels for editing text, a floating action button, snackbar, tabs and a motion and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found