Limited offer — lifetime access:$75$60
Rive · Android

Using Rive icons in Android

RiveAnimationView handles rendering. fireState() in Kotlin triggers the Hover and Click animations.

1

Add the Rive dependency

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

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

Drop the .riv file in res/raw

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

3

Add RiveAnimationView to your layout

Reference the file and configure the artboard and animation in XML.

XML
<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

Trigger state machines in Kotlin

Get the view by ID and use fireState() or setBooleanState() to trigger the Hover and Click animations.

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

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

// Fire the click trigger
riveView.fireState("State Machine 1", "Clicked")

// Set hover on touch down/up
riveView.setBooleanState("State Machine 1", "Hover", true)   // touch down
riveView.setBooleanState("State Machine 1", "Hover", false)  // touch up

Common questions

Where does the .riv file go?

In app/src/main/res/raw/. Reference it as @raw/filename in XML, without the extension.

How do I trigger hover on touch?

Use a touch listener — call setBooleanState("State Machine 1", "Hover", true) on ACTION_DOWN, then false on ACTION_UP.

Can I load from a URL?

Yes. Use riveView.setRiveUrl(url) with INTERNET permission in your manifest.

Get your animated icons

Browse icons ready for Android — free to download.

Browse icons