Massive shoutout to @Joseinnewworld for grabbing 7 of our #NFTs! Your support means the world to us as creators. You’re a true legend! 🤩🔥 #eCash $XEC #nftcollector #NFTDrop #BlockchainSimplicity #NFT #NFT4season #NFTMint #PayButton As usual, I'm preparing an #NFT #gift for you pic.twitter.com/gYdYIEhwZB
— Gaexe (@gaexe_) January 24, 2025
It is mentioned in its documentation that Snackbars provide light feedback about an operation. They display a short message at the bottom of the screen on mobile devices and the bottom left on larger devices.
Is there any other alternative we can use to display the snackbar at the top of the screen instead of the bottom? I am currently confused on how to do it.
Solution
It is very possible to do this, you just need to modify the layout of the Snackbar, here's how.
CoordinatorLayout coordinatorLayout=(CoordinatorLayout)findViewById(R.id.coordinatorLayout); Snackbar snackbar = Snackbar.make(coordinatorLayout, "Text" , Snackbar.LENGTH_LONG); View view = snackbar.getView(); CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams(); params.gravity = Gravity.TOP; view.setLayoutParams(params); snackbar.show();