Compose

Image

----___<<<<< 2023. 4. 30. 21:40

 

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
DefaultTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
SetImage()
}
}
}
}
}
@Composable
fun SetImage(){
Image(
painter = painterResource(id = R.drawable.bok),
contentDescription = "bok"
)
}
//@Composable
//fun SetImage(){
// AsyncImage(
// model = "https://tistory1.daumcdn.net/tistory/3101186/attach/639b0d9d365a4ecf832ea1d7d6735808",
// contentDescription = "bok"
// )
//}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
SetImage()
}
}
view raw MainActivity.kt hosted with ❤ by GitHub

 

'Compose' 카테고리의 다른 글

xml to compose  (0) 2023.05.05
Intent  (0) 2023.05.04
remember  (0) 2023.04.30
TextField  (0) 2023.04.29
Button / Toast  (0) 2023.04.29