WalkingSnackbar is a small library to help you implement own snackbar layout with custom position and animation in easily.
WalkingSnackbar.make(view , message , decorator)
You need to add Decorator interface in third parameter of .make(view , message , decorator)
object : WalkingSnackbar.Decorator { override fun contentIn(view: View) { ObjectAnimator.ofFloat( view, View.TRANSLATION_X, -500f, 0f ).start() }override fun withCustomLayout( inflater: LayoutInflater, containerView: ViewGroup ): View? { val binding = CustomSnackBarBinding.inflate( inflater, containerView, false ) binding.tv.text = "Oh my god custom message" return binding.root }
contentIn(view: View)
will called when you start .show()
This method is to add animation when snackbar start
withCustomLayout(inflater: LayoutInflater,containerView: ViewGroup): View?
to add custom layout binding , default snackbar will use when return null
For first parameter view
When you add one of view in your layout hierarchy , (not WalkingSnackbarContainer view) then it will search up to suitable parent view
Default searching behaviour of snackbar)
WalkingSnackbarContainer
view , then it will use it as parent to customize your viewgroup position and measurement .
When you add WalkingSnackbarContainer
view in your layout hierarchy
and you add another parent or sibling view in first parameter , then it will search WalkingSnackbarContainer
in your layout first,
and it will only use default suitale view when no WalkingSnackbarContainer
in your layout
if you have WalkingSnackbarContainer
view in your layout hierarchy , then directly add this view in parameter
because it will take parent searching with complexity
![](https://github.com/ZayPhyo01/WalkingSnackBar/raw/main/app/image/image1.png?raw=true)
With direct add
WalkingSnackbarContainer
container view
Otherwise it will search WalkingSnackbarContainer
by using Depth First Search Algorithm
before searching suitable view as default snackbar
![](https://github.com/ZayPhyo01/WalkingSnackBar/raw/main/app/image/image2.png?raw=true)
With random added view will transver with DFS to get
WalkingSnackbarContainer