Components
Snackbar
Snackbar displays informative text
Usage
Snackbars notify users of processes that have been or will be performed by the app. They appear temporarily, towards the bottom of the screen. They must not interfere with the user experience, and they do not require user input to disappear.
Basic Usage
Basic use of snackbars in fragments and in activities without customization
Normal Snackbar
Using Extension Function*
...with(binding) {btnNormalTitleOnly.setOnClickListener {normalSnackBar("Sample Text!")}}...
Using Builder Pattern
...with(binding) {btnNormalTitleOnly.setOnClickListener {//Fill setup parameter with fragment or activityLgnSnackbar.setup(this) {//Your Snackbar's customization heretitle = message}.show()}
Success Snackbar
...with(binding) {btnNormalTitleOnly.setOnClickListener {successSnackBar("Sample Text!")}}...
Using Builder Pattern
...with(binding) {btnNormalTitleOnly.setOnClickListener {//Fill setup parameter with fragment or activityLgnSnackbar.setup(this) {//Your Snackbar's customization heretitle = messagetype = LgnSnackbar.ToastType.SUCCESS}.show()
Error Snackbar
...with(binding) {btnNormalTitleOnly.setOnClickListener {errorSnackBar("Sample Text!")}}...
Using Builder Pattern
...with(binding) {btnNormalTitleOnly.setOnClickListener {//Fill setup parameter with fragment or activityLgnSnackbar.setup(this) {//Your Snackbar's customization heretitle = messagetype = LgnSnackbar.ToastType.ERROR}.show()
Warning Snackbar
...with(binding) {btnNormalTitleOnly.setOnClickListener {warningSnackBar("Sample Text!")}}...
Using Builder Pattern
...with(binding) {btnNormalTitleOnly.setOnClickListener {//Fill setup parameter with fragment or activityLgnSnackbar.setup(this) {//Your Snackbar's customization heretitle = messagetype = LgnSnackbar.ToastType.WARNING}.show()
Advanced Usage
Further use of the snackbar in fragments and in activities with customization such as:
- Title
- Description
- Action Button
- Duration
- etc
...with(binding) {btnNormalTitleImageButton.setOnClickListener {//Fill setup parameter with fragment or activityLgnSnackbar.setup(this) {//Your Snackbar's customization heretitle = "Sample Text!"avatarUrl = "https://cdn.kincir.com/2/cojC8OAR0YiByhyEPOO6AADzHrc9p3w7CTursS4z35A/transform/rs:fit:764/src/production/2021-02/740x435_3576f9505b43dabaea0294436ab365775c42fe56.jpg"actionText = "Button"
Attribute
Attribute Name | Xml Attrs | Related method(s) | Description |
---|---|---|---|
Type Snackbar | N/A | type | To set Snackbar Type |
View Anchor | N/A | view | To set Snackbar Anchor View |
Description Text | N/A | description | To set Snackbar Description |
Title Text | N/A | title | To set Snackbar Title |
Duration Snackbar | N/A | duration | To set Snackbar Duration |
Action Text | N/A | actionText | To set Snackbar Action Text |
Icon Drawable | N/A | icon | To set Snackbar Icon |
Avatar Url | N/A | avatarUrl | To set Snackbar Avatar Url |
Callback Button | N/A | setActionButtonListener { //Action } | To set Snackbar Callback Action Button |
Do you have feedback?
Please let us know to make it better