以下部基准线对齐一行内的icon和text

TopAppBar(backgroundColor = green2) {
var baseLine by remember { mutableStateOf(0f)}
val topBaselinePadding = with(LocalDensity.current) { baseLine.toDp() }
Icon(
painter = painterResource(id = R.drawable.ic__home),
contentDescription = "分类",
modifier = Modifier.padding(start = 6.dp, top = 3.dp, bottom = topBaselinePadding)
)
Text(
text = "Cat facts",
modifier = Modifier
.padding(start = 20.dp)
.paddingFromBaseline(bottom = topBaselinePadding),
style = TextStyle(fontFamily = FontFamily(Font(R.raw.font1)), fontSize = 48.sp),
onTextLayout = { baseLine = it.size.height - it.lastBaseline}
)
}

以下部基准线对齐一行内的icon和text

上一篇:vue-element-admin访问接口配置


下一篇:第三次上机实验