import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
@Composable
fun GreetingScreen() {
Column(
modifier = androidx.compose.ui.Modifier.padding(16.dp)
) {
Text(text = "Hello, Jetpack Compose")
Spacer(modifier = androidx.compose.ui.Modifier.height(8.dp))
Button(onClick = {}) {
Text(text = "Click Me")
}
}
}
@Preview(showBackground = true)
@Composable
fun GreetingScreenPreview() {
GreetingScreen()
}We created a composable function GreetingScreen that shows a text and a button vertically using a Column. We added padding and spacing for better layout.
The @Preview annotation on GreetingScreenPreview allows Android Studio to render this composable in the design preview pane. The showBackground = true parameter adds a background so the preview is clearer.
This setup helps developers see UI changes instantly without running the app on a device or emulator.