Skip to content

Instantly share code, notes, and snippets.

@TuenTuenna
Last active July 26, 2022 08:00
Show Gist options
  • Save TuenTuenna/ad4481ebb90e715d02c840acfcfa2a13 to your computer and use it in GitHub Desktop.
Save TuenTuenna/ad4481ebb90e715d02c840acfcfa2a13 to your computer and use it in GitHub Desktop.
Android Compose random 칼라 가져오기 입니다

Android Compose random 칼라 가져오기 입니다

익스텐션에 추가해 줍니다.

import androidx.compose.ui.graphics.Color
import kotlin.random.Random

// 랜덤 칼라 가져오기 
fun Color.Companion.random() : Color {
    val red = Random.nextInt(256)
    val green = Random.nextInt(256)
    val blue = Random.nextInt(256)
    return Color(red, green, blue)
}

사용 예시

Surface(
    color = Color.Companion.random(),
    modifier = Modifier.fillMaxSize()
) {
    Column(modifier = Modifier.padding(8.dp)) {
        Text(text = "회원가입 화면")
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment