How to design an icon in Snack bar?

60 Views Asked by At

Is there any way to put a button on Snack bar to do some actions like canceling , undo or closing the snack bar with clicking on a designed icon? i'm usin Kotlin and Xml in android studio

tried using actions but i want an icon to be clickable

1

There are 1 best solutions below

0
C.F.G On

Adding an action

To add an action, use the setAction method on the object returned from make. Snackbars are automatically dismissed when the action is clicked.

To show a snackbar with a message and an action:

Snackbar.make(contextView, R.string.text_label, Snackbar.LENGTH_LONG)
    .setAction(R.string.action_text) {
        // Responds to click on the action
    }
    .show()