Compose

coil

----___<<<<< 2023. 5. 13. 22:32
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
) {
ImageScreen("https://tistory1.daumcdn.net/tistory/3101186/attach/639b0d9d365a4ecf832ea1d7d6735808")
}
}
}
}
}
@Composable
fun ImageScreen(imageUrl: String) {
val context = LocalContext.current
val imageLoader = ImageLoader.Builder(context).build()
val painter = rememberAsyncImagePainter(
model = imageUrl,
imageLoader = imageLoader
)
Image(
painter = painter,
contentDescription = null,
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Fit
)
}
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
DefaultTheme {
ImageScreen("https://tistory1.daumcdn.net/tistory/3101186/attach/639b0d9d365a4ecf832ea1d7d6735808")
}
}
view raw MainActivity.kt hosted with ❤ by GitHub

'Compose' 카테고리의 다른 글

surface  (0) 2023.06.03
coil + navigation  (0) 2023.05.15
사진첩 앱 리스트  (0) 2023.05.13
Box  (0) 2023.05.13
LazyVerticalGrid + Navigation  (0) 2023.05.11