Add margins to Snackbar view

前端 未结 17 1484
时光取名叫无心
时光取名叫无心 2020-12-06 16:20

I\'m updating my current app to use snackbars, in the Google spec they show various ways of using them http://www.google.com/design/spec/components/snackbars-toasts.html#sna

17条回答
  •  清歌不尽
    2020-12-06 17:11

    My solution in Kotlin extension:

        fun showSnackBarWithConfirmation(text: String, view: View, action: () -> Unit)  =
            Snackbar.make(view, text, Snackbar.LENGTH_LONG).apply {
                this.view.findViewById(R.id.snackbar_text)
                    .setTextColor(view.context.color(R.color.colorBackgroundLight))
                this.view.setBackgroundResource(view.context.color(R.color.colorBackgroundLight))

    setAction(view.context.getString(R.string.common_ok)) { action.invoke() } (this.view.layoutParams as ViewGroup.MarginLayoutParams) .apply { setMargins(56,0,56,300) } show() }

提交回复
热议问题