admin管理员组文章数量:1026900
I recently updated material libraries and as I see now there is extra horizontal space around thumb, but could not find any info about how to remove it. Has anyone found a way to solve this issue?
CompositionLocalProvider(LocalRippleConfiguration provides null) {
Slider(
value = sliderValue,
onValueChange = { newValue ->
sliderValue = newValue
onValueChange(newValue)
},
valueRange = valueRange,
steps = steps,
thumb = {
Image(
painter = painterResource(R.drawable.ic_thumb_inverted),
contentDescription = null,
modifier = Modifier
.size(48.dp)
.testTag("thumb"),
)
},
track = { sliderState ->
SliderDefaults.Track(
drawStopIndicator = {},
modifier = Modifier
.scale(scaleX = 1f, scaleY = 0.8f),
sliderState = sliderState,
colors = SliderDefaults.colors(
activeTrackColor = neonBlue,
activeTickColor = Color.Transparent,
inactiveTickColor = Color.Transparent,
inactiveTrackColor = linkWater2Blue,
thumbColor = Color.Transparent,
),
)
},
modifier = Modifier
.constrainAs(slider) {
start.linkTo(parent.start)
end.linkTo(parent.end)
top.linkTo(parent.top)
width = Dimension.fillToConstraints
}
.testTag("slider"),
)
}
I recently updated material libraries and as I see now there is extra horizontal space around thumb, but could not find any info about how to remove it. Has anyone found a way to solve this issue?
CompositionLocalProvider(LocalRippleConfiguration provides null) {
Slider(
value = sliderValue,
onValueChange = { newValue ->
sliderValue = newValue
onValueChange(newValue)
},
valueRange = valueRange,
steps = steps,
thumb = {
Image(
painter = painterResource(R.drawable.ic_thumb_inverted),
contentDescription = null,
modifier = Modifier
.size(48.dp)
.testTag("thumb"),
)
},
track = { sliderState ->
SliderDefaults.Track(
drawStopIndicator = {},
modifier = Modifier
.scale(scaleX = 1f, scaleY = 0.8f),
sliderState = sliderState,
colors = SliderDefaults.colors(
activeTrackColor = neonBlue,
activeTickColor = Color.Transparent,
inactiveTickColor = Color.Transparent,
inactiveTrackColor = linkWater2Blue,
thumbColor = Color.Transparent,
),
)
},
modifier = Modifier
.constrainAs(slider) {
start.linkTo(parent.start)
end.linkTo(parent.end)
top.linkTo(parent.top)
width = Dimension.fillToConstraints
}
.testTag("slider"),
)
}
Share
Improve this question
edited Dec 3, 2024 at 10:05
BenjyTec
11.2k4 gold badges24 silver badges50 bronze badges
asked Nov 16, 2024 at 15:24
Javokhir SherbaevJavokhir Sherbaev
1512 silver badges7 bronze badges
0
1 Answer
Reset to default 3The Material3 Design Guidelines specify that there should be this gap of width 6.dp
on both sides of the handle. However, you can modify this using the thumbTrackGapSize
parameter of SliderDefaults.Track
Composable:
Slider(
//...
track = { sliderState ->
SliderDefaults.Track(
sliderState = sliderState,
thumbTrackGapSize = 0.dp,
//...
)
}
)
Output:
I recently updated material libraries and as I see now there is extra horizontal space around thumb, but could not find any info about how to remove it. Has anyone found a way to solve this issue?
CompositionLocalProvider(LocalRippleConfiguration provides null) {
Slider(
value = sliderValue,
onValueChange = { newValue ->
sliderValue = newValue
onValueChange(newValue)
},
valueRange = valueRange,
steps = steps,
thumb = {
Image(
painter = painterResource(R.drawable.ic_thumb_inverted),
contentDescription = null,
modifier = Modifier
.size(48.dp)
.testTag("thumb"),
)
},
track = { sliderState ->
SliderDefaults.Track(
drawStopIndicator = {},
modifier = Modifier
.scale(scaleX = 1f, scaleY = 0.8f),
sliderState = sliderState,
colors = SliderDefaults.colors(
activeTrackColor = neonBlue,
activeTickColor = Color.Transparent,
inactiveTickColor = Color.Transparent,
inactiveTrackColor = linkWater2Blue,
thumbColor = Color.Transparent,
),
)
},
modifier = Modifier
.constrainAs(slider) {
start.linkTo(parent.start)
end.linkTo(parent.end)
top.linkTo(parent.top)
width = Dimension.fillToConstraints
}
.testTag("slider"),
)
}
I recently updated material libraries and as I see now there is extra horizontal space around thumb, but could not find any info about how to remove it. Has anyone found a way to solve this issue?
CompositionLocalProvider(LocalRippleConfiguration provides null) {
Slider(
value = sliderValue,
onValueChange = { newValue ->
sliderValue = newValue
onValueChange(newValue)
},
valueRange = valueRange,
steps = steps,
thumb = {
Image(
painter = painterResource(R.drawable.ic_thumb_inverted),
contentDescription = null,
modifier = Modifier
.size(48.dp)
.testTag("thumb"),
)
},
track = { sliderState ->
SliderDefaults.Track(
drawStopIndicator = {},
modifier = Modifier
.scale(scaleX = 1f, scaleY = 0.8f),
sliderState = sliderState,
colors = SliderDefaults.colors(
activeTrackColor = neonBlue,
activeTickColor = Color.Transparent,
inactiveTickColor = Color.Transparent,
inactiveTrackColor = linkWater2Blue,
thumbColor = Color.Transparent,
),
)
},
modifier = Modifier
.constrainAs(slider) {
start.linkTo(parent.start)
end.linkTo(parent.end)
top.linkTo(parent.top)
width = Dimension.fillToConstraints
}
.testTag("slider"),
)
}
Share
Improve this question
edited Dec 3, 2024 at 10:05
BenjyTec
11.2k4 gold badges24 silver badges50 bronze badges
asked Nov 16, 2024 at 15:24
Javokhir SherbaevJavokhir Sherbaev
1512 silver badges7 bronze badges
0
1 Answer
Reset to default 3The Material3 Design Guidelines specify that there should be this gap of width 6.dp
on both sides of the handle. However, you can modify this using the thumbTrackGapSize
parameter of SliderDefaults.Track
Composable:
Slider(
//...
track = { sliderState ->
SliderDefaults.Track(
sliderState = sliderState,
thumbTrackGapSize = 0.dp,
//...
)
}
)
Output:
本文标签: kotlinHow to remove the extra padding around the thumb of a SliderStack Overflow
版权声明:本文标题:kotlin - How to remove the extra padding around the thumb of a Slider? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745654893a2161538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论