I want to show a Snackbar
and use an image instead of text for the action.
I use the following code:
val imageSpan = ImageSpan(this, R.drawable.star)
val builder = SpannableStringBuilder(" ")
builder.setSpan(
imageSpan,
0,
1,
SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE
)
Snackbar.make(findViewById(R.id.container), "Hello Snackbar", Snackbar.LENGTH_INDEFINITE)
.setAction(builder) {}.show()
drawable_star
being a vector graphic asset, but the same happens with a png
.
On an Android device lvl 26 and above this yields:
as expected, whereas on device lvl 25 the image is not visible:
Does someone know the reason for this and if there a workaround?
PS: You can check out my test project here: https://github.com/fmweigl/SpannableTest