Deep Dive: Dynamic Overlays
The flexibility of Runtime Resource Overlays (RROs) has led to powerful new paradigms in Android development, enabling system-wide dynamic theming and simplified application architectures.
Fabric: Dynamic Theming via Overlays
"Fabric" refers to the concept of applying sweeping, system-wide aesthetic changes on the fly. This is the underlying technology that powers features like Material You (Monet) in modern Android versions.
When a user changes their wallpaper, the system extracts a color palette. Instead of having apps manually query and apply these colors, the system generates or enables an RRO that redefines the core framework color tokens (e.g., @android:color/system_accent1_500).
Because every app relying on the standard Material Design components references these framework tokens, enabling the dynamic overlay instantly themes the entire OS and all compliant third-party apps without requiring them to write custom theming logic.
OEM Customization via RRO
Before RROs, OEMs (Original Equipment Manufacturers) had to fork the AOSP codebase and directly modify framework resources to apply their custom UI skins (like Samsung's One UI or Xiaomi's MIUI). This caused massive merge conflicts when upgrading to a new Android version.
With RROs, OEMs can leave the core AOSP framework untouched. They place all their custom icons, dimensions, and colors into separate overlay APKs in the /vendor or /product partitions.
This modular approach drastically reduces the time required to port a custom skin to a new Android release, significantly improving the delivery speed of major OS updates to consumers.
Self-Targeting Overlays (Android 10+)
Starting in Android 10, developers can use RROs for their own third-party applications by creating self-targeting overlays.
This means an app can ship with multiple overlay APKs embedded within its primary installation or downloaded later. The app can then use the OverlayManager APIs to enable or disable its own overlays at runtime.
This is highly useful for:
- A/B Testing: Dynamically swapping out a complex UI layout for a subset of users to measure engagement.
- Premium Themes: Allowing users to unlock and apply custom icon packs or color schemes that are managed purely via the resource system, rather than through complex custom View logic in Java or Kotlin.
Self-targeting overlays simplify the main codebase, as the app's business logic remains completely decoupled from its various visual states.