Рабочий пример:
val animation = AnimationDrawable()
animation.isOneShot = true
val resources: Resources = resources
var totalDuration = 0L
val oneFrameDuration = 28
var logoId: Int?
for (i in 1..95) {
logoId = resources.getIdentifier(
"logo${i}",
"drawable",
packageName
) // get resource id by name
ContextCompat.getDrawable(applicationContext, logoId)?.let { animation.addFrame(it, oneFrameDuration) }
totalDuration += oneFrameDuration
}
binding.imageViewSplash.background = animation
animation.start()