0Pricing
Kotlin Multiplatform Academy · Lekcja

Współdzielone obrazy, czcionki i napisy

Korzystanie z compose-resources na każdej platformie

Współdzielone obrazy, czcionki i napisy to bezpłatna lekcja Kotlin Multiplatform Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Kotlin Multiplatform Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Kotlin Multiplatform Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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. 🎨

Często zadawane pytania

Czy lekcja „Współdzielone obrazy, czcionki i napisy” jest bezpłatna?

Tak — pełny tekst „Współdzielone obrazy, czcionki i napisy” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Kotlin Multiplatform Academy, przejdź na CoddyKit PRO. Kurs Kotlin Multiplatform Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Współdzielone obrazy, czcionki i napisy”?

Korzystanie z compose-resources na każdej platformie Ćwiczysz Kotlin Multiplatform Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Kotlin Multiplatform Academy?

Nie wymagamy żadnego doświadczenia. Kotlin Multiplatform Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.

Ile czasu zajmuje lekcja „Współdzielone obrazy, czcionki i napisy”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Kotlin Multiplatform Academy?

Tak. Każda lekcja Kotlin Multiplatform Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Nawigowanie między współdzielonymi ekranami
  2. Przekazywanie argumentów i deep linków
  3. Współdzielone obrazy, czcionki i napisy
  4. Lokalizowanie tekstów współdzielonego interfejsu
← Powrót do Kotlin Multiplatform Academy