我想自定义 jetpack compose 中选项卡的外观,这是我的选项卡现在的样子:
但我想像这样查看我的选项卡:
我正在这样创建选项卡
TabRow(
selectedTabIndex = pagerState.currentPage,
backgroundColor = MaterialTheme.colors.primary,
contentColor = Color.White
) {
filters.forEachIndexed { index, filter ->
Tab(
text = {
Text(
text = filter.name.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(Locale.getDefault())
} else {
it.toString()
}
}
)
},
selected = pagerState.currentPage == index,
onClick = { scope.launch { pagerState.animateScrollToPage(index) } },
)
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现这种外观,我已经搜索了很多,但没有找到任何线索,有人可以帮忙吗?
假设我在下面编写了以下代码。
背景洋红色圆圈,顶部有默认黑色的文本。
当文本颜色位于圆圈上方时,我想将其混合为白色。
Canvas(
modifier = Modifier.size(256.dp),
onDraw = {
drawCircle(
color = Color.Magenta,
radius = 50f,
center = Offset(
x = size.width / 2,
y = size.height / 2),
)
val textSize = textMeasurer.measure(text = AnnotatedString("A"))
drawText(
textMeasurer = textMeasurer,
text = "A",
style = TextStyle(
color = Color.Black,
fontSize = 14.sp
),
topLeft = Offset(
x = size.width / 2 - 100f - (textSize.size.width / 2),
y = size.height / 2 - (textSize.size.height / 2)
)
)
drawText( …Run Code Online (Sandbox Code Playgroud) android android-canvas android-jetpack-compose android-jetpack-compose-canvas
android android-jetpack-compose android-jetpack-compose-canvas