Skip to content

Instantly share code, notes, and snippets.

@alphadoAppDev
Created April 24, 2022 04:41
@Composable
fun ButtonContainer(){
val buttonBorderGradient = Brush.horizontalGradient(listOf(Color.Yellow, Color.Red))
// remember{ } : 변경이 발생하면 뷰를 다시 그린다.
val interactionSource = remember { MutableInteractionSource() }
val isPressed by interactionSource.collectIsPressedAsState()
val pressStatusTitle = if(isPressed) "버튼을 누르고 있다" else "버튼에서 손을 뗐다."
Button(
elevation = ButtonDefaults.elevation(
defaultElevation = 10.dp,
pressedElevation = 0.dp,
disabledElevation = 0.dp
),
enabled = true,
shape = RoundedCornerShape(10.dp),
border = BorderStroke(4.dp, buttonBorderGradient),
colors = ButtonDefaults.buttonColors(
backgroundColor = Color.Black,
disabledBackgroundColor = Color.LightGray
),
interactionSource = interactionSource,
onClick = {
Log.d("TAG","Button 4가 클릭 되었다.")
}) {
Text(text = "Button 4", color = Color.White)
}
Text(text = pressStatusTitle)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment