Compose Glance: Build Android Widgets the Modern Way 🪟✨
Widgets are back in style - and with Android 16 + Material You, they're a big part of how users interact with your app. The best part? You can now build them using Jetpack Compose Glance, which brings a Compose-like API to home-screen widgets.
No RemoteViews. No XML gymnastics. Just clean, declarative UI.
🔹 What is Compose Glance?
A Jetpack library that lets you build app widgets using a simplified, Compose-inspired syntax. It isn't full Compose, but it feels familiar - Column, Row, Text, Button, modifiers, etc.
Glance is perfect for:
- ✓ Quick actions
- ✓ Status summaries
- ✓ Shortcuts
- ✓ At-a-glance info
⚡ The Smallest Example
Here's a tiny widget in Glance:
class GreetingWidget : GlanceAppWidget() {
@Composable
override fun Content() {
Column(
modifier = GlanceModifier
.padding(16.dp)
.background(Color.White)
) {
Text("Hello from Glance 👋")
Button(
text = "Open App",
onClick = actionStartActivity<MainActivity>()
)
}
}
}And register it:
class GreetingWidgetReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget = GreetingWidget()
}That's a full widget - no XML, no RemoteViews, no boilerplate.
💡 Why Use Glance?
- ✨ Declarative and Compose-like
- ✨ Material You support
- ✨ Small footprint
- ✨ Easy updates via
updateAppWidgetState() - ✨ Faster iteration vs classic widgets
Glance brings your home screen up to the level your app already runs on.
🪄 TL;DR
Compose Glance makes widgets fun again. If you've avoided widgets because of old APIs, this is your moment to try them:
- ✨ Simple
- ✨ Declarative
- ✨ Material You-ready
Your users get useful, glanceable info. You get clean, modern widget code.