๐Ÿ› ๏ธ AI Tools for Android Developers

How to Generate Jetpack Compose UI with AI

AI tools can turn a screenshot or a description into Compose code in seconds. That's a great start, but rarely production-ready. This guide shows a workflow: generate, then systematically fix state, theming, accessibility and performance, with prompts that reduce rework.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 3 min read ๐ŸŽฏ Intermediate
On this page
  1. The workflow
  2. A prompt that produces better drafts
  3. Typical fixes after generation
  4. Review checklist for generated UI
  5. Where AI UI generation shines
  6. Frequently asked questions
  7. Conclusion

Building UI from a design mockup is repetitive: rows, columns, paddings, typography. AI is good at that first draft. It's weaker at the things that make UI production-quality: correct state ownership, your design tokens, accessibility, and behaviour on different screen sizes.

The workflow

AI-assisted Compose UI workflow Start from a design image or description with project rules, generate a stateless composable draft with previews, then refactor for state hoisting and design tokens, check accessibility and adaptive layout, and finally add screenshot and UI tests. Designimage + rules Generatedraft + preview Refactorstate, tokens Checka11y, adaptive Testscreenshots
Generation is step two of five. The remaining steps turn a picture into a component you can maintain.

A prompt that produces better drafts

Prompt for generating a screenText
Create a Jetpack Compose screen matching the attached design.
Constraints:
- Stateless composable `OrderSummaryContent(state: OrderSummaryUiState, onPay: () -> Unit, onEditAddress: () -> Unit, modifier: Modifier = Modifier)`.
- Define `OrderSummaryUiState` as an immutable data class with only the fields the UI needs.
- Use MaterialTheme colorScheme, typography and shapes only (no hard-coded colors or font sizes).
- Use stringResource placeholders for user-facing text (list the string keys at the end).
- Content descriptions for icons; touch targets at least 48dp.
- Use LazyColumn for the item list with stable keys.
- Add @Preview for light, dark and fontScale 1.5 with realistic sample data.
Don't add ViewModels, navigation or networking.

Typical fixes after generation

Before: typical AI draft (problems annotated)Kotlin
@Composable
fun OrderSummary() {
    var items by remember { mutableStateOf(listOf("Mug", "T-shirt")) }      // โŒ state owned here, fake data
    Column(Modifier.padding(16.dp).background(Color(0xFFF5F5F5))) {          // โŒ hard-coded color
        Text("Order Summary", fontSize = 22.sp, fontWeight = FontWeight.Bold) // โŒ hard-coded typography
        items.forEach { Text(it) }                                            // โŒ not lazy, no keys
        Icon(Icons.Default.Edit, contentDescription = null,                    // โŒ no description, tiny target
            modifier = Modifier.size(16.dp).clickable { })
        Button(onClick = { }) { Text("Pay โ‚น1,298") }                          // โŒ action not hoisted
    }
}
After: production-readyKotlin
data class OrderSummaryUiState(val items: List<OrderLineUi>, val totalText: String, val address: String)
data class OrderLineUi(val id: String, val name: String, val priceText: String)

@Composable
fun OrderSummaryContent(
    state: OrderSummaryUiState,
    onPay: () -> Unit,
    onEditAddress: () -> Unit,
    modifier: Modifier = Modifier,
) {
    Column(modifier.fillMaxSize().background(MaterialTheme.colorScheme.surface).padding(16.dp)) {
        Text(stringResource(R.string.order_summary_title), style = MaterialTheme.typography.headlineSmall)
        LazyColumn(Modifier.weight(1f).padding(vertical = 8.dp)) {
            items(state.items, key = { it.id }) { line ->
                ListItem(headlineContent = { Text(line.name) }, trailingContent = { Text(line.priceText) })
            }
        }
        Row(verticalAlignment = Alignment.CenterVertically) {
            Text(state.address, Modifier.weight(1f), style = MaterialTheme.typography.bodyMedium)
            IconButton(onClick = onEditAddress) {                                   // 48dp target by default
                Icon(Icons.Default.Edit, contentDescription = stringResource(R.string.edit_address))
            }
        }
        Button(onClick = onPay, modifier = Modifier.fillMaxWidth()) {
            Text(stringResource(R.string.pay_amount, state.totalText))
        }
    }
}

Review checklist for generated UI

  • โ˜ Stateless: data in, events out; no fake data or local business state
  • โ˜ Theme tokens only: no hard-coded colours, sizes or fonts
  • โ˜ Strings in resources; formatted amounts from state
  • โ˜ Accessibility: content descriptions, 48dp targets, contrast, sensible reading order
  • โ˜ Lists are lazy with stable keys
  • โ˜ Works at large font scale, dark mode, small and wide screens
  • โ˜ Previews and screenshot tests added

Where AI UI generation shines

First drafts from mockups

Saves layout boilerplate, with you refining structure and tokens.

Preview generation

Realistic preview data and multi-config previews for existing composables.

Variants

Empty, loading and error states derived from an existing design.

Frequently asked questions

Can AI match my design system exactly?

Only if it knows it. Provide your theme and components in context, or rules telling it to use AppButton and similar, then review.

Is generated UI accessible?

Often partially. Check with Android Studio's accessibility checks, TalkBack, and screenshot tests at large font scale.

Should I generate whole screens or components?

Components or single screens with clear boundaries. Large generations are harder to review and fix.

Conclusion

Use AI to draft Compose UI quickly, then make it production-ready with state hoisting, theme tokens, string resources, accessibility, lazy lists and tests. Better prompts reduce the clean-up, but review is always required.

Next step: apply the same discipline to logic in Using AI to Write Kotlin Code Responsibly.

Official references

๐Ÿ“ฑ Apps built by Yunok Tech

Real Android apps on Google Play, free to download.

See all our apps โ†’

Ready to build real Android applications?

AI coding tools multiply what you already know. The stronger your Kotlin, Compose and architecture foundation, the better you can judge, fix and ship what these tools suggest.

Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.

Explore the Android course and take your next step as an Android developer.

Share: LinkedIn X / Twitter WhatsApp