setRiveResource

fun setRiveResource(@RawRes resId: Int, artboardName: String? = null, animationName: String? = null, stateMachineName: String? = null, autoplay: Boolean = controller.autoplay, autoBind: Boolean = false, fit: Fit = Fit.fromIndex(fitIndexDefault), alignment: Alignment = Alignment.fromIndex(alignmentIndexDefault), loop: Loop = Loop.fromIndex(loopIndexDefault))

Load the resource ID as a Rive file into the view.

Parameters

resId

The resource ID to load.

artboardName

Optionally provide an named artboard to use. Defaults to the first artboard in the file.

animationName

Optionally provide an named animation to load. If not supplied, playing will default to the first animation.

stateMachineName

Optionally provide a named state machine to load.

autoplay

Enable autoplay to start the animation automatically.

fit

Configure how the animation should be resized to fit its container.

alignment

Configure how the animation should be aligned to its container.

loop

Configure if animations should loop, play once, or ping-pong back and forth. Defaults to the setup in the Rive file.

Throws

if artboardName or animationName are set and do not exist in the file.