Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
In this article, you’ll build an interactive button with the Animated API that moves to a random position when selected. You’ll start with the hello-world template and add animation functionality to create a smooth, interactive experience in your Fire TV app. Vega supports three main approaches for animations: the Animated API (built into React Native), React Native Reanimated, and Lottie. This tutorial focuses on the Animated API, which requires no additional dependencies and is perfect for learning animation fundamentals.

Prerequisites

Import Animated API and useRef()

Open your App.tsx file and update the imports at the top. Add useRef() to the React import and add Animated to the react-native imports.
The useRef() hook creates a persistent reference for your animation value, while Animated provides React Native’s animation library for creating smooth animations.

Define the position reference

Inside the App component, add a position reference after the useState() line.
This creates a position reference using useRef() to store the x and y coordinates. This value persists across component re-renders.

Create the animation function

Add this function inside the App component, before the return statement.
This creates an animation that moves the image to a random position over 1 second (1000 milliseconds).

Wrap the image with Animated.View

Find the image View in your return statement and wrap it with Animated.View. Before:
After:
The position.getLayout() call applies the animated x and y values to the View’s style.

Make the image clickable

Wrap the Image with a TouchableOpacity component to make it clickable. First, update your imports.
Then update the image section.

Test the animation

Build and run the project on the Vega Virtual Device:
Now when you select the image on the right side of the screen, it animates to a random position.
Last modified on July 30, 2026