So I have added a snackbar to notify user on success or failure... but the text and icon are not properly aligned and I can't figure out how to properly do it
fun notifyUserMessage(context: Context, contextView: View, message: String,
notificationType: NotificationTypes = NotificationTypes.ERROR){
val builderTextLeft = SpannableStringBuilder()
builderTextLeft.append(" $message")
builderTextLeft.setSpan(ImageSpan(context, R.drawable.ic_alertcircle), 0, 1, 0)
builderTextLeft.setSpan(
AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0,
builderTextLeft.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
val snackbar = Snackbar.make(contextView, builderTextLeft, Snackbar.LENGTH_LONG)
.setBackgroundTint(context.getColor(setBackground(notificationType)))
.setTextColor(context.getColor(R.color.gainsboro_00))
val params = snackbar.view.layoutParams as FrameLayout.LayoutParams
params.gravity = Gravity.TOP
params.height = 250
snackbar.animationMode = BaseTransientBottomBar.ANIMATION_MODE_FADE
snackbar.show()
}
but the result looks like :
I would like the text properly aligned with the icon but also make sure that the "text+icon" are both centered in the snackbar.
Any idea ?