Inline complex XML resources  |  Views  |  Android Developers Skip to main content / English Deutsch Español – América Latina Français Indonesia Italiano Polski Português – Brasil Tiếng Việt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文 – 简体 中文 – 繁體 日本語 한국어 Android Studio Sign in Home Guides Home Guides Android Studio Architecture for Views Recommendations for Android architecture About view binding Migrate from Kotlin synthetics to view binding Data binding library About data binding Get started Layouts and binding expressions Work with observable data objects Generated binding classes Binding adapters Bind layout views to Architecture Components Two-way data binding Lifecycle for Views Handling lifecycles with lifecycle-aware components Save UI states ViewModel overview Create ViewModels with dependencies ViewModel Scoping APIs Saved State module for ViewModel ViewModel APIs cheat sheet LiveData Use Kotlin coroutines with lifecycle-aware components Paging for Views Page from network and database Transform data streams Manage and present loading states Test your Paging implementation Load and display paged data Migrate to Paging 3 About Paging 2 Display paged lists Load paged data Dependency injection for Views Dependency injection with Hilt Manual dependency injection Hilt testing guide App entry points for Views The activity lifecycle App resources for Views App resources overview Handle configuration changes Localize your app Complex XML resources Drawable Layout Animation String resources Color state list Menu Font Style More types UI layer for Views UI layer UI events UI State production Android Developers Develop Core areas UI Views Guides Inline complex XML resources Stay organized with collections Save and categorize content based on your preferences. Certain resource types are a composition of multiple complex resources represented by XML files. One example is an animated vector drawable, which is a drawable resource encapsulating a vector drawable and an animation. This requires the use of at least three XML files, as shown in the following examples. res/drawable/avd.xml <?xml version="1.0" encoding="utf-8"?> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/vectordrawable" > <target android:name="rotationGroup" android:animation="@anim/rotation" /> </animated-vector> res/drawable/vectordrawable.xml <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="64dp" android:width="64dp" android:viewportHeight="600" android:viewportWidth="600" > <group android:name="rotationGroup" android:pivotX="300.0" android:pivotY="300.0" android:rotation="45.0" > <path android:fillColor="#000000" android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" /> </group> </vector> res/anim/rotation.xml <?xml version="1.0" encoding="utf-8"?> <objectAnimator xmlns:android="http://schemas.android.com/apk/android" android:duration="6000" android:propertyName="rotation" android:valueFrom="0" android:valueTo="360" /> If the vector drawable and animations are re-used elsewhere, this is the best way to implement an animated vector drawable. But if these files are only used for this animated vector drawable, then there is a more compact way to implement them. Using AAPT’s inline resource format, you can define all three resources in the same XML file, as shown in the following example. For an animated vector drawable, put the file under res/drawable/. res/drawable/avd.xml <?xml version="1.0" encoding="utf-8"?> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" > <aapt:attr name="android:drawable" > <vector android:height="64dp" android:width="64dp" android:viewportHeight="600" android:viewportWidth="600" > <group android:name="rotationGroup" android:pivotX="300.0" android:pivotY="300.0" android:rotation="45.0" > <path android:fillColor="#000000" android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" /> </group> </vector> </aapt:attr> <target android:name="rotationGroup"> <aapt:attr name="android:animation" > <objectAnimator android:duration="6000" android:propertyName="rotation" android:valueFrom="0" android:valueTo="360" /> </aapt:attr> </target> </animated-vector> The XML tag <aapt:attr > tells AAPT to treat the tag’s child as a resource and extract it into its own resource file. The value in the attribute name specifies where to use the inline resource within the parent tag. AAPT generates resource files and names for all the inline resources. Applications built using this inline format are compatible with all versions of Android. Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates. Last updated 2026-05-18 UTC. [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-05-18 UTC."],[],[]] X Follow @AndroidDev on X YouTube Check out Android Developers on YouTube LinkedIn Connect with the Android Developers community on LinkedIn More Android Android Android for Enterprise Security Source News Blog Podcasts Discover Gaming Machine Learning Health & Fitness Camera & Media Privacy 5G Android Devices Large screens Wear OS ChromeOS devices Android for cars Android TV Releases Android 17 Android 16 Android 15 Android 14 Android 13 Android 12 Android 11 Documentation and Downloads Android Studio guide Developers guides API reference Download Studio Android NDK Support Report platform bug Report documentation bug Google Play support Join research studies Android Chrome Firebase Google Cloud Platform All products Privacy License Brand guidelines Manage cookies Get news and tips by email Subscribe English Deutsch Español – América Latina Français Indonesia Italiano Polski Português – Brasil Tiếng Việt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文 – 简体 中文 – 繁體 日本語 한국어