반응형
@Composable
fun ScaleTrack(
color: Color,
width: Float = 1f,
height: Dp = 1.dp,
rangeSize: Int, // It's (maxValue - minValue) / steps
modifier: Modifier = Modifier
) {
Canvas(
modifier = modifier
.fillMaxSize()
) {
val horizontalHeight = size.height / 2
drawLine(
color = color,
start = Offset(0f, horizontalHeight),
end = Offset(size.width, horizontalHeight),
strokeWidth = width,
StrokeCap.Butt
)
for (i in 0 .. rangeSize) {
val xOffset: Float = if (i == 0) 0f else (i / rangeSize.toFloat()) * size.width
val yOffset = (size.height - height.toPx()) / 2
drawLine(
color = color,
start = Offset(xOffset, 0f + yOffset),
end = Offset(xOffset, size.height - yOffset),
strokeWidth = width,
StrokeCap.Butt
)
}
}
}
compose slide를 사용하여 0, 1, 2 같이 딱 떨어지는 수로 조정할 때 각 값마다 눈금을 추가
반응형
'안드로이드 > 개발관련(Kotlin)' 카테고리의 다른 글
Glide Loading (Compose) (0) | 2024.07.30 |
---|---|
텍스트를 클릭하여 이벤트를 실행하는 Text (Compose) (0) | 2024.07.30 |
분할 화면 (Compose) (0) | 2024.07.30 |
화면 분할 및 크기 조절 (Layout Split) (0) | 2024.05.15 |
[Android] Number Picker (0) | 2024.01.03 |