A first Android app teaches the basic loop: write code, run the app, inspect the result, and make a small change. The goal is not to build something complex. The goal is to understand the workflow.
The Main Entry Point
In a Compose project, your main screen usually starts from MainActivity.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Greeting("Android")
}
}
}
onCreate runs when the activity is created. setContent tells Android to show Compose UI.
A Simple Composable
@Composable
fun Greeting(name: String) {
Text(text = "Hello, $name")
}
@Composable marks a function that can describe UI. Instead of editing XML, you write UI using Kotlin functions.
Preview
Compose previews let you see UI without running the full app.
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
Greeting("Junior Android Developer")
}
Preview is helpful, but still run the app on a device. Real devices reveal behavior previews cannot show.
Make It Your Own
Try adding a column with a title and subtitle:
@Composable
fun WelcomeScreen() {
Column {
Text("Hello, Android Engineer")
Text("Today we start building apps.")
}
}
If the text sticks to the top-left edge, that is normal. You will learn spacing and layout next.
Practice
Build a screen that shows your name, your current learning goal, and a button that says Start Learning. The button does not need to do anything yet.
Summary
Your first app introduces MainActivity, setContent, composable functions, and previews. Once this workflow feels familiar, every new concept becomes easier to test.