Jetpack Compose 를 사용해야하는 이유

안드로이드 스튜디오의 버전은 Arctic Fox 부터라고 한다

이전 버전의 스튜디오에서 실행했더니 (모르고)

Untitled

Empty Compose Activity 가 없어서 한참 찾았냄

Untitled

Untitled

layout 파일이 없다.

신기하다..

MainActivity 코드

package com.cos.jetpackcomposeex

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import com.cos.jetpackcomposeex.ui.theme.JetpackComposeExTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            JetpackComposeExTheme {
                // A surface container using the 'background' color from the theme
                Surface(color = MaterialTheme.colors.background) {
                    Greeting("Android")
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String) {
    Text(text = "Hello $name!")
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    JetpackComposeExTheme {
        Greeting("Android")
    }
}