Follwing the new android snackbar, i'm trying to set it to be positioned on a specific y coordinate. Its seems to be not even a possible.
I've tried with getting the parent of the snackbar's view, but, there's nothing to be done to the parent for it to set the position of it.
mSnackBar.getView().getParent();
When digging into the actual class, there's an instance of mView, and mParent which is private, and can't be reached anyhow.
https://developer.android.com/reference/android/support/design/widget/Snackbar.html
It is possible to set the location that the Snackbar is displayed by positioning a
android.support.design.widget.CoordinatorLayout
within your existing Activity layout.For example, say your existing layout is a
RelativeLayout
you could add aCoordinatorLayout
as follows:Then, make sure you pass the
CoordinatorLayout
as the first argument of theSnackbar.make()
command.This will result in the Snackbar being shown at the bottom of the
CoordinatorLayout
provided to the make() function.If you pass a
View
that is not aCoordinatorLayout
the Snackbar will walk up the tree until it finds aCoordinatorLayout
or the root of the layout.Defining a layout explicitly for the Snackbar may not always be practical.
The issue seems to have been targeting the parent, rather than the Snackbar.