Что заменяет Compose: прощай, XML
Почему декларативный пользовательский интерфейс лучше императивного создания View.
«Что заменяет Compose: прощай, XML» — бесплатный урок Jetpack Compose Academy на CoddyKit. Это урок 1 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Jetpack Compose Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Jetpack Compose Academy содержит 4 уроков всего.
Части этого урока еще не переведены и отображаются на английском.
Meet Jetpack Compose
Jetpack Compose is Android's modern toolkit for building UI in pure Kotlin. No more XML layout files. You describe screens with simple functions. 🎉
The Old Way: XML Layouts
For years, Android UI lived in XML files. You wrote markup describing views, then inflated and wired them up in Kotlin code separately.
<LinearLayout android:orientation="vertical">
<TextView android:text="Hello" />
</LinearLayout>Two Files, One Screen
The painful part was the split: layout lived in XML, behavior in Kotlin. You kept them in sync by hand, and findViewById glued them together.
Imperative vs Declarative
Old views were imperative: you found a widget and mutated it step by step, like textView.text = name. You told the UI exactly how to change.
Describe, Don't Mutate
Compose is declarative: you describe what the screen should look like for the current data, and the framework figures out the changes for you.
Text("Hello, " + name)UI as a Function of State
The core idea: UI is a function of state. Give Compose your data, it draws the screen. Change the data, it redraws what differs.
Goodbye findViewById
No more findViewById and no view binding boilerplate. You reference UI directly as Kotlin functions, so a whole class of null and id bugs disappears.
Less Code, One Language
Everything is Kotlin now. Layout, logic, and styling live together, so the same screen takes far fewer lines and stays in one place.
Recomposition Keeps UI Fresh
When your data changes, Compose runs recomposition: it re-invokes the affected functions and updates only the parts of the screen that actually changed.
Compose Is Google's Future
Compose is the recommended way to build Android UI today. New tutorials, libraries, and Google samples all assume it, so learning it sets you up well.
Same Power, Less Friction
You lose nothing: Compose still gives you Material Design, animations, and lists. It just removes the XML friction that slowed everyone down.
Quick Check
Let's lock in the big shift from the old Android UI model.
Recap: Why Compose
You saw why Compose wins: pure Kotlin, declarative UI, no XML, no findViewById. Describe the screen for your data and let recomposition keep it fresh.
Часто задаваемые вопросы
Урок «Что заменяет Compose: прощай, XML» бесплатный?
Да — полный текст урока «Что заменяет Compose: прощай, XML» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Jetpack Compose Academy, подпишись на CoddyKit PRO. Курс Jetpack Compose Academy содержит 4 уроков всего.
Чему я научусь в уроке «Что заменяет Compose: прощай, XML»?
Почему декларативный пользовательский интерфейс лучше императивного создания View. Ты практикуешь Jetpack Compose Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать Jetpack Compose Academy?
Предыдущий опыт не требуется. Jetpack Compose Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 1 из 4.
Сколько времени занимает урок «Что заменяет Compose: прощай, XML»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке Jetpack Compose Academy?
Да. Каждый урок Jetpack Compose Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Что заменяет Compose: прощай, XML
- Настройка Android Studio для Compose
- Анатомия функции @Composable
- Запуск первого приложения в эмуляторе