Rive · Android

Rive in Android

Add interactive Rive animated icons to your Android app using RiveAnimationView and Kotlin state machine controls.

1

Add the Rive dependency

Open your app-level build.gradle and add the Rive Android runtime.

copy
dependencies {
    implementation 'app.rive:rive-android:4.1.0'
}
2

Place your .riv file

Download your icon from Unicorn Icons and place the .riv file in res/raw/. Create the folder if it doesn't exist.

3

Add RiveAnimationView to your layout

Reference the .riv file and configure the artboard and animation in your XML layout.

copy
<app.rive.runtime.kotlin.RiveAnimationView
    android:id="@+id/riveView"
    android:layout_width="150dp"
    android:layout_height="150dp"
    app:riveResource="@raw/your_animation"
    app:riveArtboard="Main"
    app:riveAnimation="Idle"
    app:riveAutoplay="true" />
4

Control the animation in Kotlin

Use the view reference to play, pause, or switch animations and fire state machine inputs.

copy
val riveView = findViewById<RiveAnimationView>(R.id.riveView)

// Play an animation
riveView.play("Idle")

// Pause or switch
riveView.pause()
riveView.setAnimation("Click")

// Fire a state machine trigger
riveView.fireState("State Machine 1", "Trigger")
Get your icons
Browse animated icons ready for Android.
Browse free icons →