{"id":20093105,"url":"https://github.com/lottiefiles/dotlottie-android","last_synced_at":"2026-06-03T06:00:42.586Z","repository":{"id":212865946,"uuid":"725891506","full_name":"LottieFiles/dotlottie-android","owner":"LottieFiles","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-02T09:34:44.000Z","size":129172,"stargazers_count":131,"open_issues_count":26,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-06-02T11:19:03.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LottieFiles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-01T04:49:14.000Z","updated_at":"2026-05-30T01:29:49.000Z","dependencies_parsed_at":"2023-12-22T04:26:44.146Z","dependency_job_id":"9c8df58f-e8ef-4083-a23b-8b3761877c99","html_url":"https://github.com/LottieFiles/dotlottie-android","commit_stats":null,"previous_names":["lottiefiles/dotlottie-android"],"tags_count":53,"template":false,"template_full_name":null,"purl":"pkg:github/LottieFiles/dotlottie-android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LottieFiles%2Fdotlottie-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LottieFiles%2Fdotlottie-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LottieFiles%2Fdotlottie-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LottieFiles%2Fdotlottie-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LottieFiles","download_url":"https://codeload.github.com/LottieFiles/dotlottie-android/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LottieFiles%2Fdotlottie-android/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33850627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T16:45:53.656Z","updated_at":"2026-06-03T06:00:42.579Z","avatar_url":"https://github.com/LottieFiles.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\"https://lottie.host/c254e158-7a32-4fd5-8822-405f42e178d9/XYe7rtDZEf.svg\"\n    alt=\"dotLottie Web\"\n    width=\"550\"\n  /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003edotLottie Android\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://android-arsenal.com/api?level=21\"\u003e\u003cimg alt=\"API\" src=\"https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://jitpack.io/#LottieFiles/dotlottie-android\"\u003e\u003cimg alt=\"API\" src=\"https://jitpack.io/v/LottieFiles/dotlottie-android.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/LottieFiles/dotlottie-rs/releases/tag/v0.1.47\"\u003e\u003cimg alt=\"API\" src=\"https://img.shields.io/badge/dotlottie--rs-0.1.47-blue\"/\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e  \nA powerful Android library for rendering Lottie and dotLottie animations with advanced features like interactivity and theming\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n## Introduction\n\n**dotLottie Android** is a comprehensive Android library for rendering Lottie and dotLottie animations. It provides a simple and intuitive API for loading, playing, and controlling animations, as well as advanced features like interactivity, theming, and state machines. Built with [dotLottie-rs](https://github.com/LottieFiles/dotlottie-rs) for high-performance rendering, it supports both traditional Android Views and Jetpack Compose.\n\n### What is dotLottie?\n\ndotLottie is an open-source file format that bundles one or more Lottie animations along with their assets into a single, compressed `.lottie` file. It uses ZIP compression for efficient storage and distribution. The format also supports advanced features like:\n\n- **Interactive animations** with state machines\n- **Dynamic theming** for customizable appearances\n- **Multi-animation support** in a single file\n- **Efficient compression** for smaller file sizes\n\nThis makes dotLottie a powerful tool for creating dynamic and interactive animations that go beyond traditional Lottie capabilities.\n\n[Learn more about dotLottie](https://dotlottie.io)\n\n## Demo\n\nYou can find and run the sample application in the `sample` directory.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"/assets/preview-1.gif\" width=\"32%\"/\u003e\n\u003c/p\u003e\n\n## Installation\n\nTo add DotLottie Android, you need to add this dependency to your module's gradle file:\n\n```kotlin\nrepositories {\n    maven(url = \"https://jitpack.io\")\n}\n```\n\n```kotlin\ndependencies {\n    implementation(\"com.github.LottieFiles:dotlottie-android:0.5.0\")\n}\n```\n\n## Getting started\n\nIf your Android application is built using XML layouts, you simply need to add `DotLottieAnimation` to your layout file and define parameters such as speed, animation source, etc.\n\n### Using XML\n\nFirst, place your animation in the assets folder of your Android project and add `DotLottieAnimation` to your XML file:\n\n```xml\n    \u003ccom.lottiefiles.dotlottie.core.widget.DotLottieAnimation\n        android:id=\"@+id/lottie_view\"\n        android:layout_width=\"200dp\"\n        app:speed=\"3\"\n        app:src=\"swinging.json\"\n        android:layout_height=\"200dp\" /\u003e\n```\n\n### Using Kotlin code\n\nIn your Kotlin code, get a reference to the component you added to your layout. This gives you access to methods that allow you to interact with the animation:\n\n```kotlin\nval dotLottieAnimationView = findViewById\u003cDotLottieAnimation\u003e(R.id.lottie_view)\n```\n\nSet up the initial animation configuration:\n\n#### Traditional UI\n\n```kotlin\nimport com.lottiefiles.dotlottie.core.model.Config\n\nval config = Config.Builder()\n    .autoplay(true)\n    .speed(1f)\n    .loop(true)\n    .source(DotLottieSource.Url(\"https://lottiefiles-mobile-templates.s3.amazonaws.com/ar-stickers/swag_sticker_piggy.lottie\"))\n//    .source(DotLottieSource.Asset(\"file.json\")) // asset from the asset folder .json or .lottie\n//    .source(DotLottieSource.Res(R.raw.animation)) // resource from raw resources .json or .lottie\n    .useInterpolation(true)\n    .playMode(Mode.Forward)\n    .build()\ndotLottieAnimationView.load(config)\n```\n\n### Using JetPack Compose\n\n```kotlin\nimport com.lottiefiles.dotlottie.core.compose.ui.DotLottieAnimation\nimport androidx.compose.ui.graphics.Color\nimport androidx.compose.ui.Modifier\nimport com.lottiefiles.dotlottie.core.util.DotLottieSource\nimport com.dotlottie.dlplayer.Mode\n\nfun ExampleComposeComponent() {\n    DotLottieAnimation(\n        source = DotLottieSource.Url(\"https://lottiefiles-mobile-templates.s3.amazonaws.com/ar-stickers/swag_sticker_piggy.lottie\"), // from url .lottie / .json\n//        source = DotLottieSource.Asset(\"file.json\"), // from asset .lottie / .json\n//        source = DotLottieSource.Res(R.raw.animation), // from raw resources .json or .lottie\n//        source = DotLottieSource.Json(\"{\"v\":\"4.8.0\",\"meta\":{\"g\":\"LottieFiles ..........\"), // lottie json string\n//        source = DotLottieSource.Data(ByteArray), // dotLottie data as ByteArray\n        autoplay = true,\n        loop = true,\n        speed = 3f,\n        useFrameInterpolation = false,\n        playMode = Mode.FORWARD,\n        modifier = Modifier.background(Color.LightGray)\n    )\n}\n```\n\n#### Controlling player using JetPack Compose\n\n```kotlin\nimport com.lottiefiles.dotlottie.core.compose.ui.DotLottieAnimation\nimport com.lottiefiles.dotlottie.core.compose.runtime.DotLottieController\nimport com.lottiefiles.dotlottie.core.util.DotLottieSource\nimport com.dotlottie.dlplayer.Mode\n\nfun ExampleComposeComponent() {\n    val dotLottieController = remember { DotLottieController() }\n\n    // This effect runs once when the composable enters the composition\n    LaunchedEffect(UInt) {\n        dotLottieController.setLoop(true)\n        dotLottieController.setSpeed(3f)\n        // You can control the animation directly using the controller\n        dotLottieController.play()\n\n        // In a real app, you would call these methods from button clicks\n        // or other user events.\n        // For example:\n        // Button(onClick = { dotLottieController.pause() }) { Text(\"Pause\") }\n        // Button(onClick = { dotLottieController.stop() }) { Text(\"Stop\") }\n    }\n\n    DotLottieAnimation(\n        source = DotLottieSource.Url(\"https://lottiefiles-mobile-templates.s3.amazonaws.com/ar-stickers/swag_sticker_piggy.lottie\"), // url of .json or .lottie\n        autoplay = false,\n        loop = false,\n        speed = 1f,\n        useFrameInterpolation = false,\n        playMode = Mode.FORWARD,\n        controller = dotLottieController\n    )\n}\n\n```\n\n## State Machine Support\n\nDotLottie Android supports interactive animations with state machines for advanced user interactions:\n\n### Loading State Machines\n\n```kotlin\n// Load state machine by ID from .lottie file\ndotLottieAnimationView.stateMachineLoad(\"state_machine_id\")\n\n// Or load state machine from JSON data\ndotLottieAnimationView.stateMachineLoadData(stateMachineJsonData)\n\n// Start the state machine\ndotLottieAnimationView.stateMachineStart()\n```\n\n### State Machine Events\n\nMonitor state machine events by implementing `StateMachineEventListener`:\n\n```kotlin\nprivate val stateMachineListener = object : StateMachineEventListener {\n    override fun onStateEntered(enteringState: String) {\n        Log.d(TAG, \"Entered state: $enteringState\")\n    }\n\n    override fun onStateExit(leavingState: String) {\n        Log.d(TAG, \"Exited state: $leavingState\")\n    }\n\n    override fun onTransition(previousState: String, newState: String) {\n        Log.d(TAG, \"Transitioned from $previousState to $newState\")\n    }\n\n    override fun onNumericInputValueChange(inputName: String, oldValue: Float, newValue: Float) {\n        Log.d(TAG, \"Input $inputName changed from $oldValue to $newValue\")\n    }\n\n    override fun onStringInputValueChange(inputName: String, oldValue: String, newValue: String) {\n        Log.d(TAG, \"Input $inputName changed from $oldValue to $newValue\")\n    }\n\n    override fun onBooleanInputValueChange(inputName: String, oldValue: Boolean, newValue: Boolean) {\n        Log.d(TAG, \"Input $inputName changed from $oldValue to $newValue\")\n    }\n\n    override fun onInputFired(inputName: String) {\n        Log.d(TAG, \"Input fired: $inputName\")\n    }\n\n    override fun onCustomEvent(message: String) {\n        Log.d(TAG, \"Custom event: $message\")\n    }\n\n    override fun onError(message: String) {\n        Log.e(TAG, \"State machine error: $message\")\n    }\n}\n\n// Add the listener\ndotLottieAnimationView.addStateMachineEventListener(stateMachineListener)\n```\n\n### State Machine Input Controls\n\n```kotlin\n// Set input values\ndotLottieAnimationView.stateMachineSetNumericInput(\"inputName\", 42.0f)\ndotLottieAnimationView.stateMachineSetStringInput(\"inputName\", \"value\")\ndotLottieAnimationView.stateMachineSetBooleanInput(\"inputName\", true)\n\n// Get input values\nval numericValue = dotLottieAnimationView.stateMachineGetNumericInput(\"inputName\")\nval stringValue = dotLottieAnimationView.stateMachineGetStringInput(\"inputName\")\nval booleanValue = dotLottieAnimationView.stateMachineGetBooleanInput(\"inputName\")\n\n// Fire events\ndotLottieAnimationView.stateMachineFireEvent(\"eventName\")\n\n// Get current state\nval currentState = dotLottieAnimationView.stateMachineCurrentState()\n\n// Stop state machine\ndotLottieAnimationView.stateMachineStop()\n```\n\n## Performance Optimization\n\n### Multi-threading Support\n\nDotLottie Android supports multi-threaded rendering for improved performance. You can specify the number of threads to use for rendering:\n\n#### Traditional UI\n\n```kotlin\nval config = Config.Builder()\n    .source(DotLottieSource.Asset(\"animation.lottie\"))\n    .threads(6u) // Use 6 threads for rendering\n    .autoplay(true)\n    .loop(true)\n    .build()\n\ndotLottieAnimationView.load(config)\n```\n\n#### Jetpack Compose\n\n```kotlin\nDotLottieAnimation(\n    source = DotLottieSource.Asset(\"animation.lottie\"),\n    threads = 6u, // Use 6 threads for rendering\n    autoplay = true,\n    loop = true,\n    modifier = Modifier.size(300.dp)\n)\n```\n\n## Theme Support\n\nDotLottie Android supports dynamic theming for .lottie files:\n\n```kotlin\n// Load theme by ID from .lottie file manifest\ndotLottieAnimationView.loadTheme(\"theme_id\")\n\n// Load theme from JSON data\ndotLottieAnimationView.loadThemeData(themeJsonData)\n```\n\n## API Reference\n\n#### Playback Control\n\n- `play()`: Plays animation from the current frame.\n- `pause()`: Pauses animation at the current frame.\n- `stop()`: Stops and resets the animation to its initial frame.\n- `setSpeed(Float)`: Sets animation speed (`1f` is normal).\n- `setLoop(Boolean)`: Toggles animation looping.\n- `setPlayMode(Mode)`: Sets playback direction (e.g., `Forward`, `Reverse`).\n- `setSegment(Float, Float)`: Sets a specific frame segment to play.\n- `setMarker(String)`: Plays the animation between a named marker.\n\n#### Animation State \u0026 Properties\n\n- `isPlaying`: `true` if the animation is currently playing.\n- `isPaused`: `true` if the animation is paused.\n- `isStopped`: `true` if the animation is stopped.\n- `isLoaded`: `true` if an animation has been successfully loaded.\n- `totalFrames`: The total number of frames in the animation.\n- `currentFrame`: The current frame number.\n- `duration`: The total animation duration in seconds.\n- `speed`: The current animation speed.\n- `loop`: `true` if looping is enabled.\n- `loopCount`: The number of times the animation has looped.\n\n#### Configuration \u0026 Loading\n\n- `load(Config)`: Loads an animation with a specified configuration.\n- `setBackgroundColor(Int)`: Sets the animation's background color.\n- `setUseFrameInterpolation(Boolean)`: Toggles frame interpolation for smoother playback.\n- `setLayout(Fit, LayoutUtil.Alignment)`: Sets the animation layout configuration.\n\n#### Performance\n\n- `threads(UInt)` (Config.Builder): Sets the number of rendering threads for improved performance.\n\n#### Theming\n\n- `loadTheme(String)`: Loads a theme from the .lottie file by its ID.\n- `loadThemeData(String)`: Loads a theme from theme JSON data.\n\n#### State Machine\n\n- `stateMachineLoad(String)`: Loads a state machine by its ID.\n- `stateMachineStart()`: Starts the loaded state machine.\n- `stateMachineStop()`: Stops the state machine.\n- `stateMachineFireEvent(String)`: Fires a named event.\n- `stateMachineSetNumericInput(String, Float)`: Sets a numeric input value.\n- `stateMachineSetStringInput(String, String)`: Sets a string input value.\n- `stateMachineSetBooleanInput(String, Boolean)`: Sets a boolean input value.\n- `stateMachineGetNumericInput(String)`: Gets a numeric input value.\n- `stateMachineGetStringInput(String)`: Gets a string input value.\n- `stateMachineGetBooleanInput(String)`: Gets a boolean input value.\n- `stateMachineCurrentState()`: Returns the current state machine state.\n- `addStateMachineEventListener(StateMachineEventListener)`: Adds a listener for state machine events.\n\n#### Events\n\nIt's possible to monitor events from your animation.\nFirst, create an instance of `DotLottieEventListener` and attach it to the\n`DotLottieAnimation` component:\n\n```kotlin\nprivate val eventListener = object : DotLottieEventListener {\n    override fun onPlay() {\n        Log.d(TAG, \"onPlay\")\n    }\n\n    override fun onPause() {\n        Log.d(TAG, \"onPause\")\n    }\n\n    override fun onStop() {\n        Log.d(TAG, \"onStop\")\n    }\n\n    override fun onFrame(frame: Float) {\n        Log.d(TAG, \"frame $frame\")\n    }\n\n    override fun onComplete() {\n\n    }\n\n    override fun onDestroy() {\n\n    }\n\n    override fun onFreeze() {\n\n    }\n\n    override fun onLoad() {\n\n    }\n\n    override fun onLoop() {\n\n    }\n\n    override fun onUnFreeze() {\n\n    }\n}\n```\n\nAttach the listener to the component:\n\n```kotlin\ndotLottieAnimationView.addEventListener(eventListener)\n\n// For state machine events\ndotLottieAnimationView.addStateMachineEventListener(stateMachineListener)\n```\n\n## Building from Source with Custom Flags\n\nThis repo includes a Gradle plugin that lets you compile [dotlottie-rs](https://github.com/LottieFiles/dotlottie-rs) directly from source with custom Rust feature flags. This is useful when you need a trimmed-down binary (smaller APK) or want to enable or disable specific capabilities.\n\n### Prerequisites\n\n- [Rust toolchain](https://rustup.rs) with `cargo` on your `PATH`\n- Android NDK (the version declared in `dotlottie/build.gradle.kts` under `ndkVersion`)\n- The `deps/dotlottie-rs` submodule initialized:\n  ```bash\n  git submodule update --init --recursive\n  ```\n\n### Configuration\n\nOpen `dotlottie/build.gradle.kts` and configure the `dotlottieRust` block:\n\n```kotlin\ndotlottieRust {\n    // Enable building from source (default: false — uses pre-built .so files)\n    buildFromSource = true\n\n    // Select which optional features to include.\n    // The three core features (tvg, tvg-sw, c_api) are always included and cannot be removed.\n    // Remove any line below to disable that feature and reduce binary size.\n    features = listOf(\n        \"dotlottie\",              // .lottie zip container support\n        \"state-machines\",         // state machine support (requires dotlottie)\n        \"theming\",                // theming support (requires dotlottie)\n        \"tvg-webp\",               // WebP image support\n        \"tvg-png\",                // PNG image support\n        \"tvg-jpg\",                // JPEG image support\n        \"tvg-ttf\",                // TrueType font support\n        \"tvg-lottie-expressions\", // Lottie expression evaluation\n        \"tvg-threads\",            // multi-threaded rendering\n    )\n\n    // Build only specific CPU architectures (default: all four).\n    // Speeds up dev builds significantly:\n    // abis = listOf(\"arm64-v8a\", \"x86_64\")\n\n    // Android API level (default: 21 = Android 5.0)\n    // apiLevel = 21\n}\n```\n\n### Running the Build\n\nWith `buildFromSource = true`, the Rust library is compiled automatically before every Android build. To compile it in isolation:\n\n```bash\n./gradlew :dotlottie:buildDotLottieRs\n```\n\nBuilt `.so` files are written to `dotlottie/src/main/jniLibs/` and the C header to `dotlottie/src/main/cpp/dotlottie_player.h`.\n\n### Feature Reference\n\n| Feature | Description | Default |\n|---|---|---|\n| `dotlottie` | `.lottie` zip container parsing | included |\n| `state-machines` | Interactive state machine support | included |\n| `theming` | Dynamic theming for `.lottie` files | included |\n| `tvg-webp` | WebP image decoding | included |\n| `tvg-png` | PNG image decoding | included |\n| `tvg-jpg` | JPEG image decoding | included |\n| `tvg-ttf` | TrueType font rendering | included |\n| `tvg-lottie-expressions` | Lottie expression evaluation | included |\n| `tvg-threads` | Multi-threaded rendering | included |\n\n\u003e **Note:** `tvg`, `tvg-sw`, and `c_api` are always compiled in and cannot be removed.\n\n## Contributing\n\nWe welcome contributions! Please see our [`CONTRIBUTING.md`](CONTRIBUTING.md) file for guidelines on how to report issues, request features, and submit pull requests.\n\n## Supported ABIs\n\nThe jniLibs in this library support the following ABIs:\n\n- armeabi-v7a\n- arm64-v8a\n- x86_64\n- x86\n\nOur Jitpack release is a universal AAR that includes all supported ABIs. To reduce the size of your APK, you can exclude the ABIs that you do not require by configuring the abiFilters in your build.gradle.kts as shown below:\n\n```kotlin\nandroid {\n  defaultConfig {\n    ndk {\n      abiFilters.add(\"arm64-v8a\")\n      abiFilters.add(\"armeabi-v7a\")\n    }\n  }\n}\n```\n\n## License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flottiefiles%2Fdotlottie-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flottiefiles%2Fdotlottie-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flottiefiles%2Fdotlottie-android/lists"}