Index of every page on this site: llms.txt
All skills
android avatar

/display-glasses-with-jetpack-compose-glimmer

@7f7b217
by androidandroid/skills11k stars
703
Run it yourself

Provides guidelines for developing projected Android XR apps for display glasses using the Jetpack Compose Glimmer UI toolkit. Covers Glimmer design principles, workflows, and interaction models for the glasses form factor. Use this skill to build an Android XR Augmented Experience app with Jetpack Compose Glimmer. Don't use for audio-only AI glasses without a display, non-glasses Android XR headsets (spatial panels or 3D volumes with Jetpack Compose for XR), or phone and tablet Material 3 UIs.

Use this Skill: https://skilld.dev/gh/android/skills/display-glasses-with-jetpack-compose-glimmer

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescard-samples-source.md

≈2.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

When creating a Glimmer Card component, refer to the following implementation samples in CardSamples.kt:

/*
 * Copyright 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.xr.glimmer.samples

import androidx.annotation.Sampled
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.BrushPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.xr.glimmer.ActionCard
import androidx.xr.glimmer.Button
import androidx.xr.glimmer.ButtonGroup
import androidx.xr.glimmer.Card
import androidx.xr.glimmer.GlimmerTheme
import androidx.xr.glimmer.Icon
import androidx.xr.glimmer.ImageCard
import androidx.xr.glimmer.LeadingImageCard
import androidx.xr.glimmer.Text
import androidx.xr.glimmer.TrailingImageCard
import androidx.xr.glimmer.list.GlimmerLazyColumn

@Composable
fun CardSampleUsage() {
    GlimmerLazyColumn {
        item { CardSample() }
        item { CardWithTrailingIconSample() }
        item { CardWithTitleAndSubtitleAndLeadingIconSample() }
        item { CardWithLongText() }
        item { CardWithTitleAndSubtitleAndLeadingIconLongText() }
        item { ActionCardWithTitleSample() }
        item { ActionCardWithTitleAndLeadingIcon() }
        item { ImageCardSample() }
        item { ImageCardWithTitleAndSubtitleAndLeadingIconSample() }
        item { LeadingImageCardSample() }
        item { TrailingImageCardSample() }
        item { NonFocusableCardWithButtonGroupSample() }
    }
}

// ---
// Card samples
// ---

@Sampled
@Composable
fun CardSample() {
    Card { Text("This is a card") }
}

@Sampled
@Composable
fun CardWithTrailingIconSample() {
    Card(trailingIcon = { Icon(FavoriteIcon, "Localized description") }) {
        Text("This is a card with a trailing icon")
    }
}

@Sampled
@Composable
fun CardWithTitleAndSubtitleAndLeadingIconSample() {
    Card(
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is a card with a title, subtitle, and leading icon")
    }
}

@Sampled
@Composable
fun ClickableCardSample() {
    Card(onClick = {}) { Text("This is a card") }
}

@Sampled
@Composable
fun ClickableCardWithTrailingIconSample() {
    Card(onClick = {}, trailingIcon = { Icon(FavoriteIcon, "Localized description") }) {
        Text("This is a card with a trailing icon")
    }
}

@Sampled
@Composable
fun ClickableCardWithTitleAndSubtitleAndLeadingIconSample() {
    Card(
        onClick = {},
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is a card with a title, subtitle, and leading icon")
    }
}

@Composable
fun CardWithLongText() {
    Card {
        Text(
            "This is a card with a lot of text that will wrap to multiple lines. The maximum recommend number of lines of text for a card is 10.",
            maxLines = 10,
            overflow = TextOverflow.Ellipsis,
        )
    }
}

@Composable
fun CardWithTitleAndSubtitleAndLeadingIconLongText() {
    Card(
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text(
            "This is a card with a lot of text that will wrap to multiple lines. The maximum recommend number of lines of text for a card is 10."
        )
    }
}

@Composable
fun CardWithTitleAndSubtitleAndLeadingIconAndTrailingIconLongText() {
    Card(
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
        trailingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text(
            "This is a card with a lot of text that will wrap to multiple lines. The maximum recommend number of lines of text for a card is 10."
        )
    }
}

@Sampled
@Composable
fun NonFocusableCardWithButtonGroupSample() {
    Column(verticalArrangement = Arrangement.spacedBy(GlimmerTheme.componentSpacingValues.large)) {
        Card(focusable = false) { Text("This is a non-focusable card with a button group") }
        ButtonGroup(modifier = Modifier.fillMaxWidth()) {
            Button(onClick = {}) { Text("Button 1") }
            Button(onClick = {}) { Text("Button 2") }
            Button(onClick = {}) { Text("Button 3") }
        }
    }
}

// ---
// ActionCard samples
// ---

@Sampled
@Composable
fun ActionCardWithTitleSample() {
    ActionCard(action = { Button(onClick = {}) { Text("Send") } }, title = { Text("Title") }) {
        Text("This is an action card with a title")
    }
}

@Composable
fun ActionCardWithTitleAndLeadingIcon() {
    ActionCard(
        action = {
            Button(onClick = {}, trailingIcon = { Icon(FavoriteIcon, "Localized description") }) {
                Text("Send")
            }
        },
        title = { Text("Title") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is an action card with a title and leading icon")
    }
}

// ---
// ImageCard samples
// ---

@Sampled
@Composable
fun ImageCardSample() {
    ImageCard(
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) }
    ) {
        Text("This is an image card")
    }
}

@Sampled
@Composable
fun ImageCardWithTitleAndSubtitleAndLeadingIconSample() {
    ImageCard(
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) },
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is an image card with a title, subtitle, and leading icon")
    }
}

@Sampled
@Composable
fun ClickableImageCardSample() {
    ImageCard(
        onClick = {},
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) },
    ) {
        Text("This is an image card")
    }
}

@Sampled
@Composable
fun ClickableImageCardWithTitleAndSubtitleAndLeadingIconSample() {
    ImageCard(
        onClick = {},
        image = { Image(MyImage, "Localized description", contentScale = ContentScale.FillWidth) },
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
        leadingIcon = { Icon(FavoriteIcon, "Localized description") },
    ) {
        Text("This is an image card with a title, subtitle, and leading icon")
    }
}

// ---
// Leading/Trailing ImageCard samples
// ---

@Sampled
@Composable
fun LeadingImageCardSample() {
    LeadingImageCard(
        image = { Image(MyImage, "Localized description") },
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
    ) {
        Text("This is a card with a leading image.")
    }
}

@Sampled
@Composable
fun TrailingImageCardSample() {
    TrailingImageCard(
        image = { Image(MyImage, "Localized description") },
        title = { Text("Title") },
        subtitle = { Text("Subtitle") },
    ) {
        Text("This is a card with a trailing image.")
    }
}

// ---
// Previews
// ---

@Preview
@Composable
private fun CardPreview() {
    GlimmerTheme { CardSample() }
}

@Preview
@Composable
private fun CardWithTrailingIconPreview() {
    GlimmerTheme { CardWithTrailingIconSample() }
}

@Preview
@Composable
private fun CardWithTitleAndSubtitleAndLeadingIconPreview() {
    GlimmerTheme { CardWithTitleAndSubtitleAndLeadingIconSample() }
}

@Preview
@Composable
private fun CardWithLongTextPreview() {
    GlimmerTheme { CardWithLongText() }
}

@Preview
@Composable
private fun CardWithTitleAndSubtitleAndLeadingIconLongTextPreview() {
    GlimmerTheme { CardWithTitleAndSubtitleAndLeadingIconLongText() }
}

@Preview
@Composable
private fun CardWithTitleAndSubtitleAndLeadingIconAndTrailingIconLongTextPreview() {
    GlimmerTheme { CardWithTitleAndSubtitleAndLeadingIconAndTrailingIconLongText() }
}

@Preview
@Composable
private fun NonFocusableCardWithButtonGroupPreview() {
    GlimmerTheme { NonFocusableCardWithButtonGroupSample() }
}

@Preview
@Composable
private fun ActionCardWithTitlePreview() {
    GlimmerTheme { ActionCardWithTitleSample() }
}

@Preview
@Composable
private fun ActionCardWithTitleAndLeadingIconPreview() {
    GlimmerTheme { ActionCardWithTitleAndLeadingIcon() }
}

@Preview
@Composable
private fun ImageCardPreview() {
    GlimmerTheme { ImageCardSample() }
}

@Preview
@Composable
private fun ImageCardWithTitleAndSubtitleAndLeadingIconPreview() {
    GlimmerTheme { ImageCardWithTitleAndSubtitleAndLeadingIconSample() }
}

@Preview
@Composable
private fun LeadingImageCardPreview() {
    GlimmerTheme { LeadingImageCardSample() }
}

@Preview
@Composable
private fun TrailingImageCardPreview() {
    GlimmerTheme { TrailingImageCardSample() }
}

fun placeholderImagePainter(intrinsicSize: Size): Painter =
    BrushPainter(
        Brush.linearGradient(
            0.0f to Color(0xFF3C8CDE),
            0.4f to Color(0xFFED73A8),
            0.6f to Color(0xFFED73A8),
            1.0f to Color(0xFFE763F9),
            start = Offset.Zero,
            end = Offset(intrinsicSize.width, intrinsicSize.height),
        )
    )

/**
 * Placeholder image with a large intrinsic size, to simulate a real life use case of loading a
 * bitmap
 */
private val MyImage = placeholderImagePainter(Size(1000f, 1000f))
<br />

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts6d3 checks · Risk SAFE
  • Gen Agent Trust Hub7d

    The skill provides comprehensive guidelines and code samples for developing Android XR applications using the Jetpack Compose Glimmer UI toolkit. It follows standard Android development patterns and relies on official Android/XR libraries. No security risks were identified.

  • Socket6d

    No alerts

  • Snyk7d

    Risk: LOW · No issues

Signed by skilld at 7f7b217. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 34 minutes ago.

Activeupdated last week
Other metadata
metadata
{
  "author": "Google LLC",
  "last-updated": "2026-11-13",
  "keywords": [
    "Jetpack Compose Glimmer",
    "display glasses",
    "Projected Activity",
    "GlimmerTheme",
    "Additive Display",
    "Android XR - Augmented Experiences"
  ]
}

README badge

README badge for android/skills/display-glasses-with-jetpack-compose-glimmer