nispok / snackbar Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Android Library that implements Snackbars from Google's Material Design documentation.
License: MIT License
[DEPRECATED] Android Library that implements Snackbars from Google's Material Design documentation.
License: MIT License
Would it be possible to pause the countdown while the snackbar is being swiped? Because you may go to swipe it and while doing so the timer may run out and thus dismiss it which doesn't look right, timer should resume when the swipe is cancelled, just an idea.
The SnackbarManager should delay the showing of a new snackbar by 200-300ms (current snackbar animation out duration) so that the snackbars do not stack on top of each other. The material design spec states that only one snackbar should be visible at a time.
Hi,
First of all, great library! I have a request: currently the snackbar is always positioned to the left of the screen on tablets. As a default, this works well, but if you're using the master/detail design pattern, more fine-grained control of the snackbar's location is needed to ensure that the snackbar doesn't cover critical information or straddle the master & detail views. Can you add a method to position the snackbar? Thanks!
it's great to use SnackBar in non Lollipop android version, and have lot of option for developer,
i want to use snakeBar with RightToLeft Direction like this :
try this code to set RTL direction, but it's not work !?
Snackbar snackbar=Snackbar.with(getApplicationContext())
.duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE)
.text("متاسفانه خطایی در ثبت مکان رخ داده است. ")
.actionLabel("بستن");
snackbar.setLayoutDirection(SnackbarLayout.LAYOUT_DIRECTION_RTL);
snackbar.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
SnackbarManager.show(snackbar,GetActivity());
is there any solution to set Direction Like this ?
Hi,
Thanks for this lib.
Do you have plans to support the tablet snackbar style as per the guidelines ?
In order to properly animate, for example, a FAB, it would be useful to know when the dismiss animation starts, so we can animate them together.
I took a look at the code and this seems pretty easy to do. We just need to:
A Snackbar
should hold a list of ActionClickListener
and EventListener
First of all thanks for your work, i tried and came to know SnackbarType.MULTI_LINE
isn't making any effect on device with physical screen size greater than 6.0"
. I'm using Sony's T2 Ultra and the SnackbarType.MULTI_LINE
turn into an ellipsized
text, and in smaller screen devices, it's working good.
Help is needed and appreciated
Thanks
Should slide to bottom instead of fade out. That's how Inbox does it
I use preferencefragment with nested preferencescreens. When I'm in a child preferencescreen and a snackbar is shown then it's not visible. If I press back to go back to the parent preferencescreen then I can see the snackbar that was shown in the child preference screen.
Is there a way to show snackbars in child preferencescreens?
2.5.3 fix causes problems on phone devices :)
Snackbar is now wrongly positioned way above bottom bar
Increase functionality of Snackbar by allowing it to be clicked. This would be separate from the action button.
The actionButton Color always gets srt to purple even if i specify a different color
Most likely the snackbar appeared under the keyboard
According to Material Design docs, snackbar background color should be #323232 (100%). I think it's #ff323232 right now.
Hi *,
it wold be nice, if this library also handle undo logic, so we don't need to handle two different libraries. An example is the https://github.com/jenzz/Android-UndoBar/ library. Or create something custom/ proprietary.
Thanks
Hasan
It seems that in tablet layout only a single line is shown even if you use MULTI_LINE SnackbarType.
Would it be possible to implement a dismiss listener so that you are notified when the snackbar is dismissed? I can create one for you this week if needsbe.
The parameters for onShow()
and onDismiss()
should be in pixels, not dp. The height parameter should represent the actual height of the Snackbar, not the maximum height. Also, it might be good to include the width as well for tablet layouts so we can determine if a view (e.g. FAB) needs to move out of the way only if the Snackbar is overlapping it.
I can submit a pull request for these things, but it depends on another one of my pull requests being merged in (#33).
I use a snackbar with the custom duration 10 sec. If a user presses Back when a snackbar is showing, then the activity is finished but it cannot be garbage collected because there is a strong reference to it from the handler queue (due to postDelayed() method call):
Handler -> mDismissRunnable -> Snackbar (outer class) -> Activity
I think it is needed to call removeCallbacks(mDismissRunnable); from onDetachedFromWindow(), for example.
Could you also add resource Ids for strings and colors?
I have Fragment which contains ListView placed as DrawerLayout content view. I create a Snackbar instance inside Fragment and attach it to my ListView. Then I open the drawer and Snackbar is displayed above it. In GMail app Snackbar is displayed below the opened drawer. Can I achieve similar behavior somehow?
Is it possible to change the minSKD to 14?
Hi,
thank you for your hard work and awesome library!
Is there any way to set custom height
to Snackbar
? Something like:
SnackbarManager.show(
Snackbar.with(context)
.text("Hello, world!")
.height(200) // height in dp
.duration(Snackbar.SnackbarDuration.LENGTH_LONG));
Thank you in advance!
Snackbar crashes, because textview in snackbar.xml and color in colors.xml had named by the same id snackbar_text.
It throw java.lang.NoSuchFieldError: No static field snackbar_text of type I in class Lcom/nispok/snackbar/R$id; or its superclasses (declaration of 'com.nispok.snackbar.R$id' at com.nispok.snackbar.Snackbar.init(Snackbar.java:226)
Hello,
I'm using your lib and it works pretty well on all devices I've tested it, but just discovered that on version 4.4.2 (At least on LG G3) when using translucentNavigation bar the snackbar is shown behind the navigation bar. Neither clipToPadding nor fitsSystemWindows solve the problem.
Screenshot : https://s3.amazonaws.com/pushbullet-uploads/udqLC-dxEqYkHwmGpyu7qBM3kgN24ksiAwphAE/Screenshot_2014-12-12-20-08-34.png
Thanks in advanced
According to the material design spec for snackbars, this video indicates that a swipe down should be the method for dismissing a snackbar instead of a horizontal swipe. Can you please change the behavior, or at the minimum, at least add support for swipe to dismiss direction?
Support should be added for including left and right drawables for richer notifications to the user.
If i change this Toast to snackbar. It prompts a Error.
public void showToast(final String message)
{
this.handler.post(new Runnable()
{
public void run()
{
Toast.makeText(RemoteIt.this, message, Toast.LENGTH_SHORT).show();
}
});
}
Hey!
First of all - thanks for a superb library.
Secondly - maybe it would be nice to have a String tag (or something) to identify a Snackbar and update already showing, or simply remove the previous Snack?
Feature request: snackbars are seemingly intended as replacements for toasts in Android. However, toasts are not dependent on Activities, they only need a Context, meaning that they can be used from services as well, for instance. Any thoughts about reworking Snackbars to match that behavior?
According to the Material Design spec, the action button text should be Roboto Medium, while the message text should be Roboto Regular. I was looking into how to do this, but there doesn't seem to be an easy solution.
One option would be to bundle the Roboto Medium (and Roboto Regular?) fonts with the library and set the TextViews accordingly.
Another option is to add a dependency for a library like
https://github.com/johnkil/Android-RobotoTextView
or
https://github.com/chrisjenx/Calligraphy
I also just came across https://bitbucket.org/josephearl/foundry, which might be helpful.
Any other ideas/thoughts?
How about choosing the animation? Like bouncing, fading, coming from left to right or the other way around?
I was testing my app on an 4.0.3 emulated device and realized that the snackbar was not actually showing at the bottom of the screen but at an higher offset.
The emulated device I was using does not have navigation button but it does the same for devices with navigation buttons on 4.0.3. To help pin point the problem, this activity is using the new appcompat v7 Toolbar where the activity is set with no action bar and the new toolbar is somewhat part of the content for pre-android 5 devices.
Great lib!
Is there a way to adjust the snackbar position according to the navbars visibility?
Thanks,
Jon.
The Material Design Spec Sections "App Errors" and "Incompatible state errors" show snackbars being used to communicate different error states:
http://www.google.com/design/spec/patterns/errors.html#errors-app-errors
"Consider displaying an unintrusive but persistent indicator when users are in these states."
However the current implementation requires a definite duration to show. I propose adding a constant SnackbarDuration.INDEFINITE which would keep it on screen, needing to be dismissed by swipe or action.
Hi,
I've received a null pointer crash on the com.nispok.snackbar.listeners.SwipeDismissTouchListener.onTouch method.
Here is a full report of the crash that might bring you some extra information http://crashes.to/s/5a796486a4a
Thanks in advanced
If I show a snackbar in response to a button clicked in a dialog, it shows behind the dialog's dim layer. It should appear on top of everything when summoned IMO
For some reason, the SnackBar isn't showing after dismissing a ProgressDialog. There's no error output on logcat.
Thanks for the library, its great ;).
Unfortunatelly, the snackbar cannot be white :
https://stackoverflow.com/questions/27939154/cant-set-color-to-white-in-snackbar-android?noredirect=1#comment44275721_27939154
Provide a SnackbarManager similar to the one used in the sample app to handle a Snackbar queue
I believe it is not defined in the Material Design Guideline. And the new inbox application does not do it. You cannot swipe there. I think it shouldn't be enabled by default.
I see following problem:
When I first add a fragment and this fragment shows a snackbar, everything works. If I remove the fragment and readd a new one, the snackbar shown from the fragment is behind this new fragment... I see it, because when I press back and remove the new fragment and reattach the previous one again, I see the snackbar over the previous fragment...
What works for me, as a work around, is following:
mCurrentSnackbar.show(parent);
mCurrentSnackbar.postDelayed(new Runnable()
{
@Override
public void run()
{
mCurrentSnackbar.bringToFront();
}
}, 500);
After rotating the device the Snackbar is gone. I'm using SnackbarDuration.LENGTH_INDEFINITE
so it should stay.
I guess this is the intended behavior, because it's just a view. Does someone have a best practice for this problem?
Would it be possible to allow "showing" to place the snackbar as a child of a parent view? This would fix the problem with having to adjust views to show outside of it (FloatingActionButton's, etc).
I really need to show more than 2 lines. I fixed it but the fix is ugly. Please support more than 2 lines against the material design rules.
final Snackbar snackbar = Snackbar.with(this)
.text(error)
.actionLabel(R.string.close)
.duration(Snackbar.SnackbarDuration.LENGTH_LONG)
.dismissOnActionClicked(true)
.type(SnackbarType.MULTI_LINE);
snackbar.show(this);
// fix: Snackbar doesn't support more than 2 lines.
TextView snackbarText = (TextView) snackbar.findViewById(R.id.sb__text);
snackbarText.setMaxLines(25);
snackbar.setMaxHeight(ViewHelper.dpToPx(context, 400));
snackbar.requestLayout();
Using on a 5.0.1 Nexus 7 and version 2.6.0 of this library, swiping to dismiss snackbar causes snackbar to change in size on swipe.
Video Example: https://www.dropbox.com/s/exjl4p2fwfzmmgk/device-2014-12-19-140101.mp4?dl=0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.