/android-display-glasses-with-jetpack-compose-glimmer:display-glasses-with-jetpack-compose-glimmerfrom android-display-glasses-with-jetpack-compose-glimmer
Provides guidelines for building Android XR augmented experience apps for display glasses using Jetpack Compose Glimmer. Covers Glimmer design principles, workflows, interaction models, and projected activity setup.
Ships in android-display-glasses-with-jetpack-compose-glimmer. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
| Term | Definition |
|---|---|
| Intelligent eyewear | Hands-free eyewear with speakers, camera, and microphone (audio-only or display). |
| Display glasses | Eyewear with a private in-lens display for glanceable visuals and audio. |
| Jetpack Compose Glimmer | Compose UI toolkit with components, theming, and focus for display glasses. |
| Projected activity | Host phone Activity whose UI and input are projected to connected eyewear. |
| Projected device | XR eyewear device connected to an Android host phone projecting content. |
| GlimmerTheme | Root styling provider for GlimmerColors, GlimmerTypography, GlimmerShapes. |
| Additive display | Display where black (#000000) renders 100% transparent by adding light. |
| Augmented experiences | Lightweight, additive Android XR experiences for users on the go. |
compileSdk 37 or higher (compileSdk = 37 or compileSdk { version = release(37) }).gradle/libs.versions.toml first; never guess 1.0.0-alpha01):
androidx.xr.glimmer:glimmer (1.0.0-alpha21+ or libs.androidx.glimmer)androidx.xr.glimmer:glimmer-google-fonts (1.0.0-alpha21+ or libs.androidx.glimmer.google.fonts)androidx.xr.projected:projected (1.0.0-alpha13+ or libs.androidx.xr.projected or libs.androidx.projected)MaterialTheme, Material 3 (androidx.compose.material3.*), or Material elevation or shadow modifiers inside Glimmer UI.GlimmerTheme, Glimmer components (androidx.xr.glimmer.*), DepthEffectLevels, and createGoogleSansFlexTypography() (androidx.xr.glimmer.googlefonts). Minimum text size is 18sp; avoid Thin or Hairline weights.Set up projected activity : Follow Create your first activity for
intelligent eyewear and projectedcontext-source.md. Set
android:exported="true" and android:requiredDisplayCategory to
android.hardware.display.category.XR_PROJECTED in AndroidManifest.xml:
<activity
android:name="com.example.xr.projected.ProjectedMainActivity"
android:exported="true"
android:requiredDisplayCategory="android.hardware.display.category.XR_PROJECTED">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.XR_PROJECTED_LAUNCHER"/>
</intent-filter>
</activity>
Mobile app integration : Add a Text("Launch on Glasses") button on the
host phone. Observe
ProjectedContext.isProjectedDeviceConnected(context, coroutineContext)
using collectAsStateWithLifecycle(initialValue = false) to set enabled
(so it is disabled when disconnected) and launch GlassesMainActivity with
ProjectedContext.createProjectedActivityOptions(context).toBundle():
val options = ProjectedContext.createProjectedActivityOptions(context)
val intent = Intent(context, ProjectedMainActivity::class.java)
context.startActivity(intent, options.toBundle())
Theming, initial focus, and black background : Follow
glimmersansflextypography-source.md. In onCreate (with
@OptIn(ExperimentalComposeUiApi::class)), set
ComposeUiFlags.isInitialFocusOnFocusableAvailable = true
(androidx.compose.ui.ComposeUiFlags), wrap UI in
GlimmerTheme(typography = createGoogleSansFlexTypography()), and apply
Modifier.background(Color.Black) (or GlimmerTheme.colors.background) to
the root container:
@OptIn(ExperimentalProjectedApi::class)
class ProjectedMainActivity : ComponentActivity() {
private var displayController: ProjectedDisplayController? = null
private var isVisualUiSupported by mutableStateOf(false)
private var areVisualsOn by mutableStateOf(true)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) {
displayController?.close()
displayController = null
}
})
initializeGlassesFeatures()
setContent {
GlimmerTheme {
HomeScreen(
areVisualsOn = areVisualsOn,
isVisualUiSupported = isVisualUiSupported,
onClose = { finish() }
)
}
}
}
private fun initializeGlassesFeatures() {
lifecycleScope.launch {
// Check device capabilities
val projectedDeviceController = ProjectedDeviceController.create(this@ProjectedMainActivity)
isVisualUiSupported = projectedDeviceController.capabilities.contains(CAPABILITY_VISUAL_UI)
val controller = ProjectedDisplayController.create(this@ProjectedMainActivity)
displayController = controller
val observer = GlassesLifecycleObserver(
context = this@ProjectedMainActivity,
controller = controller,
onVisualsChanged = { visualsOn -> areVisualsOn = visualsOn }
)
lifecycle.addObserver(observer)
}
}
}
Bottom-align UI (Alignment.BottomCenter), show one primary piece of info at a time (VerticalStack), and avoid multiple simultaneous cards.
Color contrast : Follow material-hct-source.md to keep at least a 70% HCT tone difference between foreground and background (#000000).
Focus and 1D input : Avoid nesting scrolling controls; use System Back to
dismiss views. For focus (androidx.compose.foundation.focusGroup and
androidx.compose.ui.focus.*) and hardware input, follow Focus in Jetpack
Compose Glimmer and Hardware Controls for display glasses:
@Composable
fun FocusSample(initialFocus: FocusRequester) {
Box(
modifier =
Modifier.focusProperties {
onEnter = {
initialFocus.requestFocus()
cancelFocusChange()
}
}
.focusGroup()
) {
Button(onClick = {}) { Text("First Button") }
}
}
Follow glimmertheme-source.md when using GlimmerTheme.
| Category | Token | Value / Role |
|---|---|---|
| Color | primary / secondary | #9BBFFF / #4C88E9 (Focal colors) |
| Color | positive / negative | #7AD48F (Confirmation) / #F57082 (Alert) |
| Color | background / surface | #000000 (Transparent) / #262626 (GlimmerTheme.colors.surface, SurfaceDefaults.border) |
| Shape | large (Standard) / small | RoundedCornerShape(36.dp) / RoundedCornerShape(12.dp) |
Pass FontVariation.Settings(FontVariation.Setting("ROND", 100f), FontVariation.width(100f), FontVariation.opticalSizing(9.sp), FontVariation.weight(...)) to createGoogleSansFlexTypography
(titleLargeVariationSettings, bodyMediumVariationSettings,
captionVariationSettings, and other role settings):
| Style | Size / Line-Height | Weight |
|---|---|---|
| Title Large / Medium / Small | 30/36.sp, 24/32.sp, 20/28.sp | 725 |
| Body Large / Medium / Small | 30/36.sp, 24/32.sp, 20/28.sp | 520 |
| Caption | 18.sp / 28.sp | 650 |
Follow deptheffect-source.md and deptheffectlevels-source.md for
DepthEffect and DepthEffectLevels: use
GlimmerTheme.depthEffectLevels.level1 for resting state and level2 for
focused state (using SurfaceDepthEffect(depthEffect = level1, focusedDepthEffect = level2) on Modifier.surface or Modifier.depthEffect):
@Composable
fun DepthEffectLevelsSample() {
val levels = GlimmerTheme.depthEffectLevels
Box(contentAlignment = Alignment.Center) {
DepthBox("Level 1", levels.level1)
DepthBox("Level 2", levels.level2)
DepthBox("Level 3", levels.level3)
DepthBox("Level 4", levels.level4)
DepthBox("Level 5", levels.level5)
}
}
@Composable
private fun DepthBox(name: String, depthEffect: DepthEffect) {
val interactionSource = remember { MutableInteractionSource() }
Box(
modifier = Modifier
.size(100.dp)
.surface(
interactionSource = interactionSource,
depthEffect = SurfaceDepthEffect(
depthEffect = depthEffect,
focusedDepthEffect = depthEffect
)
),
contentAlignment = Alignment.Center
) {
Text(name)
}
}
Never embed Card (androidx.xr.glimmer.Card) in ListItem. Follow Jetpack
Compose Glimmer: Cards, card-source.md, and
card-samples-source.md.
Clickable vs. non-clickable : Pass onClick = { ... } if the whole card is a trigger; omit onClick if informational and control focus using focusable: Boolean (such as Card(focusable = false)).
Single primary action (ActionCard) : Use
androidx.xr.glimmer.ActionCard when anchoring a primary action button to
the bottom of a card:
ActionCard(
action = {
Button(onClick = {}, trailingIcon = { Icon(FavoriteIcon, "Localized description") }) {
Text("Send")
}
}
) {
Text("This is a card with a title, leading icon, header image, and action")
}
Multiple actions (Card and ButtonGroup) : Use
androidx.xr.glimmer.ButtonGroup (rememberButtonGroupState). Never nest
ButtonGroup inside Card { ... }. Place Card(focusable = false)
above ButtonGroup as a sibling in a Column to avoid focus
contention:
ButtonGroup(modifier = Modifier.fillMaxWidth()) {
Button(onClick = {}) { Text("Button 1") }
Button(onClick = {}) { Text("Button 2") }
Button(onClick = {}) { Text("Button 3") }
Button(onClick = {}) { Text("Button 4") }
Button(onClick = {}) { Text("Button 5") }
}
val scope = rememberCoroutineScope()
val state = rememberButtonGroupState()
ButtonGroup(modifier = Modifier.fillMaxWidth(), state = state) {
Button(onClick = { scope.launch { state.animateScrollToItem(1) } }) {
Text("Select last item")
}
Button(onClick = { scope.launch { state.animateScrollToItem(0) } }) {
Text("Select first item")
}
}
Image cards : Use ImageCard, LeadingImageCard, or TrailingImageCard
(image = { ... }, title, subtitle, leadingIcon, trailingIcon) with
ContentScale.Crop, Outline (CardDefaults.shape), and maxLines = 10
on long body Text:
ImageCard(
image = {
Image(
painter = myHeaderImage,
contentDescription = "Header image",
contentScale = ContentScale.FillWidth
)
},
title = { Text("Card Title", style = GlimmerTheme.typography.titleMedium) },
subtitle = { Text("Sub-heading text", style = GlimmerTheme.typography.titleSmall) },
leadingIcon = { Icon(FavoriteIcon, contentDescription = "Favorite") },
) {
Text(
"This is the main body content of the card, utilizing theme-tokens for consistent styling.",
style = GlimmerTheme.typography.bodyMedium
)
}
Follow Jetpack Compose Glimmer: Buttons, button-source.md, and
button-samples-source.md. Use Button(onClick, buttonSize = ButtonSize.Large, color = baseColor, focusedColor = ButtonDefaults.focusedColor(baseColor)) (top-level parameters on Button,
never ButtonDefaults.colors), IconButton for stateless icon
triggers, and always use ToggleButton(checked, onCheckedChange, leadingIcon)
or IconToggleButton(checked, onCheckedChange) (never stateful IconButton)
for toggle or media playback controls:
Button(
onClick = {},
focusedColor = brandColor,
) {
Text("Focus Color Button")
}
@Composable
fun ToggleButtonWithLeadingIconSample() {
var checked by remember { mutableStateOf(false) }
ToggleButton(
checked = checked,
leadingIcon = {
Icon(
if (checked) FavoriteIcon else OutlinedFavoriteIcon,
contentDescription = "Toggle favorite"
)
},
onCheckedChange = { checked = it }
) {
Text(if (checked) "On" else "Off")
}
}
var checked by remember { mutableStateOf(false) }
val additionalColors =
IconToggleButtonDefaults.colors(checkedBackgroundColor = Color(0xFF80B799))
IconToggleButton(
checked = checked,
onCheckedChange = { checked = it },
colors = additionalColors
) {
Icon(
if (checked) FavoriteIcon else OutlinedFavoriteIcon,
contentDescription = "Toggle favorite"
)
}
TitleChip (androidx.xr.glimmer.TitleChip) is a non-interactive pill header
(three words or fewer, single line). Follow Jetpack Compose Glimmer: Title
Chips, titlechip-source.md, and titlechip-samples-source.md.
When placing a standalone TitleChip above a Card or ActionCard, center it
and space it with TitleChipDefaults.associatedContentSpacing:
@Composable
fun TitleChipWithCardSample() {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
TitleChip { Text("Title Chip") }
Spacer(Modifier.height(TitleChipDefaults.associatedContentSpacing))
Card(
title = { Text("Title") },
subtitle = { Text("Subtitle") },
leadingIcon = { Icon(FavoriteIcon, "Localized description") },
) {
Text("Card Content")
}
}
}
Follow Jetpack Compose Glimmer: Icons, icon-source.md, iconbutton-source.md, and iconsizes-source.md.
Sizing and contrast : Pass Modifier.size(GlimmerTheme.iconSizes.small),
GlimmerTheme.iconSizes.medium, or GlimmerTheme.iconSizes.large to Icon
whenever a small, medium, or large icon is needed (including inside card
icon slots). Never use Color.Black or saturated error tints; use
Color.Unspecified for multicolor vectors (tint = null on Painter). Use
Material Symbols (600 weight, Rounded, Unfilled), or build vectors
with ImageVector.Builder or painterResource if material-icons-* isn't
in app/build.gradle.kts:
@Composable
fun SizedIconSample() {
Icon(
FavoriteIcon,
contentDescription = "Localized description",
modifier = Modifier.size(GlimmerTheme.iconSizes.large),
)
}
Follow list-source.md, listitem-source.md, and liststate-source.md.
Always use GlimmerLazyColumn : Import GlimmerLazyColumn, rememberGlimmerLazyListState, and items from androidx.xr.glimmer.list (never foundation LazyColumn). Use listState.scrollToItem(0) or animateScrollToItem(0) to scroll to top.
Integrated title, spacing, and rows : Pass title = { TitleChip { Text("...") } } directly on GlimmerLazyColumn, explicitly set
verticalArrangement = Arrangement.spacedBy(20.dp), and render rows with
androidx.xr.glimmer.ListItem(onClick = { ... }, supportingLabel = { Text(...) }) { Text(...) } (never nest Card in ListItem):
@Composable
fun GlimmerLazyColumnWithTitleChipSample() {
val ingredientItems =
listOf("Milk", "Flour", "Egg", "Salt", "Apples", "Butter", "Vanilla", "Sugar", "Cinnamon")
GlimmerLazyColumn(title = { TitleChip { Text("Ingredients") } }) {
items(ingredientItems) { text -> ListItem { Text(text) } }
}
}
Use VerticalStack (androidx.xr.glimmer.stack.VerticalStack) for
heterogeneous cards one at a time (never with TitleChip). Follow
stack-source.md, stackstate-source.md, and
stackitemscope-source.md. Align to Alignment.BottomCenter, set height to
66.dp taller than the tallest card (Modifier.height(maxCardHeight + 66.dp)), and apply Modifier.itemDecoration(CardDefaults.shape) to each item's
Card:
@Composable
fun VerticalStackSample() {
VerticalStack {
item {
Card { Text("Top Card") }
}
item {
Card { Text("Second Card") }
}
item {
Card { Text("Third Card") }
}
}
}
Use GlimmerHorizontalPager
(androidx.xr.glimmer.pager.GlimmerHorizontalPager) with
rememberGlimmerPagerState(pageCount = { ... }), pageSpacing, and
pageIndicator = { GlimmerHorizontalPagerDefaults.PageIndicator(state, selectedIndicatorColor = GlimmerTheme.colors.primary, unselectedIndicatorColor = GlimmerTheme.colors.primary.copy(alpha = GlimmerHorizontalPagerDefaults.UnselectedIndicatorAlpha)) } (never foundation
HorizontalPager). Follow Jetpack Compose Glimmer: Pager. Use
pagerState.animateScrollToPage in a coroutine for programmatic scroll, and
configure Glimmer Text (androidx.xr.glimmer.Text, never Material
Text) with style = LocalTextStyle.current.copy(textMotion = TextMotion.Animated):
// Hoist the pager state, specifying the total page count with a lambda.
val pagerState = rememberGlimmerPagerState(pageCount = { 10 })
GlimmerHorizontalPager(
state = pagerState,
modifier = Modifier.fillMaxSize(),
) { page ->
// Use Glimmer components like Card and Text for optimized glasses styling.
Card(modifier = Modifier.fillMaxWidth()) {
Text(
text = "Page: $page",
// Recommended: use TextMotion.Animated for smooth transitions in a pager.
style = LocalTextStyle.current.copy(textMotion = TextMotion.Animated),
)
}
}
GlimmerHorizontalPager(
state = pagerState,
modifier = Modifier.fillMaxSize(),
// Use a page numbers instead of the default dot-indicator
pageIndicator = {
Text(
text = "${pagerState.currentPage + 1} / ${pagerState.pageCount}",
style = LocalTextStyle.current.copy(textMotion = TextMotion.Animated),
)
}
)
AlertDialog : Use androidx.xr.glimmer.AlertDialog (never
android.app or Material AlertDialog) with onDismissRequest,
confirmButton, dismissButton, icon, title, and text using Glimmer
Button, Icon, and Text:
var showDialog by remember { mutableStateOf(true) }
if (showDialog) {
AlertDialog(
onDismissRequest = { showDialog = false },
confirmButton = { Button(onClick = { /* confirm action */ }) { Text("Confirm") } },
dismissButton = { Button(onClick = { showDialog = false }) { Text("Dismiss") } },
icon = { Icon(imageVector = FavoriteIcon, contentDescription = "Alert icon") },
title = { Text("Title") },
text = { Text("This is an alert dialog with options to confirm or dismiss.") },
)
}
var showDialog by remember { mutableStateOf(true) }
if (showDialog) {
AlertDialog(
onDismissRequest = { showDialog = false },
confirmButton = { Button(onClick = { showDialog = false }) { Text("OK") } },
icon = {
Icon(
imageVector = OutlinedFavoriteIcon,
contentDescription = "Favorite icon",
)
},
title = { Text("Title") },
text = { Text("This is an alert dialog with only an option to dismiss.") },
)
}
Modifier.surface : Follow surface-source.md. Share one remember { MutableInteractionSource() } between
Modifier.surface(enabled = true, shape = GlimmerTheme.shapes.large, color = GlimmerTheme.colors.surface, depthEffect = ..., interactionSource = interactionSource) and .focusable(interactionSource = interactionSource)
or .clickable(interactionSource = interactionSource, indication = null, ...), chaining .surface(...) before .focusable(...) or
.clickable(...):
@Composable
fun FocusableSurfaceSample() {
val interactionSource = remember { MutableInteractionSource() }
Box(
modifier = Modifier
.size(100.dp)
.surface(interactionSource = interactionSource)
.focusable(interactionSource = interactionSource),
contentAlignment = Alignment.Center
) {
Text("Focusable")
}
}
@Composable
fun ClickableSurfaceSample() {
val interactionSource = remember { MutableInteractionSource() }
Box(
modifier = Modifier
.size(100.dp)
.surface(interactionSource = interactionSource)
.focusable(interactionSource = interactionSource)
.clickable(
interactionSource = interactionSource,
indication = null
) { /* Handle click action */ },
contentAlignment = Alignment.Center
) {
Text("Clickable")
}
}
Follow Jetpack Compose Glimmer: Voice Input Indicator and Jetpack Compose Glimmer: Indirect Pointer.
VoiceInputIndicator and ContainedVoiceInputIndicator : Normalize
SpeechRecognizer rmsdB values into 0.0f..1.0f using .coerceIn(0f, 1f):
// Example state variable to hold the normalized level (0.0 to 1.0)
// that the VoiceInputIndicator component expects.
val audioLevel = MutableStateFlow(0f)
// Initialize the Android SpeechRecognizer
val speechRecognizer = SpeechRecognizer.createSpeechRecognizer(context)
// Listener to capture speech events and audio level changes
val listener = object : RecognitionListener {
override fun onRmsChanged(rmsdB: Float) {
// Normalize raw dB level to a 0.0-1.0 range.
// Android SpeechRecognizer's rmsdB typically ranges from 0 to ~10.
audioLevel.value = ((rmsdB - 1f) / 9f).coerceIn(0f, 1f)
}
// ... Implement other required RecognitionListener methods ...
override fun onReadyForSpeech(params: Bundle?) {}
override fun onBeginningOfSpeech() {}
override fun onEndOfSpeech() {}
override fun onError(error: Int) {}
override fun onResults(results: Bundle?) {}
override fun onPartialResults(partialResults: Bundle?) {}
override fun onEvent(eventType: Int, params: Bundle?) {}
override fun onBufferReceived(buffer: ByteArray?) {}
}
// Attach the listener to the recognizer
speechRecognizer.setRecognitionListener(listener)
// Create an intent to specify the recognition model and behavior
val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
}
// Begin listening for audio input
speechRecognizer.startListening(intent)
@Composable
fun VoiceInputExample(modifier: Modifier) {
// Collect the flow as Compose State so the UI reacts to changes in real-time.
val currentLevel by audioLevel.collectAsState()
VoiceInputIndicator(
// The VoiceInputIndicator component provides a visual "pulse" or indicator
// that changes based on the 'level' lambda, which returns a Float between 0.0 and 1.0.
level = { currentLevel },
modifier = modifier
)
}
Modifier.onIndirectPointerGesture : Apply
androidx.xr.glimmer.onIndirectPointerGesture (onClick, onSwipeForward,
onSwipeBackward) to a container made focusable (focusTarget() or
focusable()):
@Composable
fun OnIndirectPointerGestureSample() {
var lastGesture by remember { mutableStateOf("None") }
Box(
modifier =
Modifier.fillMaxSize()
.onIndirectPointerGesture(
enabled = true,
onSwipeForward = { lastGesture = "Forward" },
onSwipeBackward = { lastGesture = "Backward" },
onClick = { lastGesture = "Click" },
)
.focusTarget(),
contentAlignment = Alignment.Center,
) {
Text("Last Gesture: $lastGesture")
}
}
references/android/design/ui/ai-glasses/guides/interaction/inputs.md (opens in a new tab)references/button-samples-source.md (opens in a new tab)references/button-source.md (opens in a new tab)references/card-samples-source.md (opens in a new tab)references/card-source.md (opens in a new tab)references/deptheffect-source.md (opens in a new tab)references/deptheffectlevels-source.md (opens in a new tab)references/glimmersansflextypography-source.md (opens in a new tab)references/glimmertheme-source.md (opens in a new tab)references/icon-source.md (opens in a new tab)references/iconbutton-source.md (opens in a new tab)references/iconsizes-source.md (opens in a new tab)references/list-source.md (opens in a new tab)references/listitem-source.md (opens in a new tab)references/liststate-source.md (opens in a new tab)references/material-hct-source.md (opens in a new tab)references/projectedcontext-source.md (opens in a new tab)references/stack-source.md (opens in a new tab)references/stackitemscope-source.md (opens in a new tab)references/stackstate-source.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Read when SKILL.md points to them.
2 plugins ship this exact skill · first indexed Nov 17, 2026
npx claudepluginhub premex-ab/claude-marketplace --plugin android-display-glasses-with-jetpack-compose-glimmerOther plugins' skills for the same job