以下部基准线对齐一行内的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}
)
}
标签:基准线,baseLine,start,text,bottom,topBaselinePadding,dp,icon 来源: https://www.cnblogs.com/--here--gold--you--want/p/15312145.html