Since I've migrated my Android Project to AndroidX i am receiving the following lint error:
Error: Must be one of: Snackbar.LENGTH_INDEFINITE, Snackbar.LENGTH_SHORT, Snackbar.LENGTH_LONG [WrongConstant]
Snackbar snackbar = Snackbar.make(rootView, message, sticky ? Snackbar.LENGTH_INDEFINITE : 4500
So instead of defining a custom duration (4500ms), I am now using Snackbar.LENGTH_LONG
.
Since i am implementing some time-based operation that depends on how long the snackbar is visible, I need to know the actual duration of Snackbar.LENGTH_LONG
in milliseconds. How do I find out that value?
The docs are not really helpful here:
Show the Snackbar for a short period of time.
After some fishing in the source code you will find these constants in the SnackbarManager
:
private static final int SHORT_DURATION_MS = 1500;
private static final int LONG_DURATION_MS = 2750;
So to answer your question the actual duration for the long length is 2750 milliseconds.
Class com.google.android.material.snackbar.SnackbarManager
: