0Pricing
Kotlin Multiplatform Academy · Aula

Imagens, fontes e strings compartilhadas

Use compose-resources em todas as plataformas

Imagens, fontes e strings compartilhadas é uma aula grátis de Kotlin Multiplatform Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Kotlin Multiplatform Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Kotlin Multiplatform Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Assets Should Be Shared Too

Your logo, your fonts, your labels: why ship them twice? compose-resources lets every platform load the same assets. 🖼️

One Resources Folder

You drop assets into a shared composeResources directory. Images, fonts and strings all live in one place for every target.

Add the Resources Setup

Enabling resources generates a typed Res object. You reference assets through it instead of raw file paths.

commonMain.dependencies {
    implementation(compose.components.resources)
}

Folders by Asset Type

Resources are grouped into folders like drawable, font and values. The names tell the toolkit how to treat each file.

Show a Shared Image

Load a drawable with painterResource and the generated Res handle. The same picture renders on both apps.

Image(
    painter = painterResource(Res.drawable.logo),
    contentDescription = "Logo"
)

Bundle a Custom Font

Place a font file in the font folder, then load it with Font and the Res handle to build a FontFamily.

val brand = FontFamily(Font(Res.font.inter_bold))

Strings in One File

Define your text in a shared strings.xml. Each label gets a key, and the Res object exposes it to your UI.

<string name="welcome">Welcome back!</string>

Read a Shared String

You fetch text with stringResource and the generated key. No more hardcoded labels scattered across screens.

Text(stringResource(Res.string.welcome))

Type Safety for Free

Because Res is generated, a typo in an asset name fails to compile. You catch missing resources before users ever do. ✅

Strings Can Take Arguments

Add placeholders in a string and pass values at call time. The same stringResource call fills them in for you.

Text(stringResource(Res.string.greeting, userName))

Assets Travel With Shared Code

Because resources live in the shared module, any app that uses your code gets the assets automatically. One source of truth. 🙂

Quick Check

Which function loads a shared drawable into a Compose Image?

Recap: Shared Look and Feel

You stored images, fonts and strings once and loaded them with the generated Res object. Every platform shares the same brand. 🎨

Perguntas Frequentes

A aula “Imagens, fontes e strings compartilhadas” é grátis?

Sim — o texto completo de “Imagens, fontes e strings compartilhadas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Kotlin Multiplatform Academy, atualize para CoddyKit PRO. O curso de Kotlin Multiplatform Academy inclui 4 aulas no total.

O que vou aprender em “Imagens, fontes e strings compartilhadas”?

Use compose-resources em todas as plataformas Você pratica Kotlin Multiplatform Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Kotlin Multiplatform Academy?

Nenhuma experiência prévia é necessária. Kotlin Multiplatform Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.

Quanto tempo leva a aula “Imagens, fontes e strings compartilhadas”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Kotlin Multiplatform Academy?

Sim. Cada aula de Kotlin Multiplatform Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Navegue entre telas compartilhadas
  2. Passe argumentos e links profundos
  3. Imagens, fontes e strings compartilhadas
  4. Localize textos da interface compartilhada
← Voltar para Kotlin Multiplatform Academy