Adding Rive to Your Project
See the Adding Rive to Your Project section for instructions on adding Rive to your Android project. Once complete, resume here.Building a RiveAnimationView
There are a number of ways to add Rive animations to your Android application. Before getting started, ensure your Rive files (.riv) are included in your Android project. The recommended way is to add them to the raw resources (res/raw) folder of your project.
Using setRiveResource or setRiveUrl
For the simplest programmatic initialization, usesetRiveResource (local) or setRiveUrl (networked) methods. They have a number of optional parameters to customize the view.
Using RiveAnimationView.Builder
Rive also provides a builder pattern for constructing aRiveAnimationView which allows for staggered initialization steps. Note that the setResource method can take a raw resource ID, a URL (string), a byte array, or a Rive File.
Using a Rive File
If you have already loaded a RiveFile instance, you can use that to initialize the view as well. See Caching a Rive File for more details on how and why to load Rive files.
Using Compose (AndroidView)
You can also useRiveAnimationView inside a Compose UI using the AndroidView composable. See also the LegacyComposeActivity in the example app.
Using XML Layouts
To use XML, include it as part of your layout. It has a number of optional attributes to customize the view.app:riveUrl attribute. Ensure you have the necessary internet permissions.
Internet Permissions
If you’re retrieving Rive files over a network, your app will need permission to access the internet inAndroidManifest.xml: