我遇到模拟器中的设计视图与真实设备上运行的实际应用程序之间的文本间距差异。与设备相比,模拟器中的文本字符和行之间的间距似乎更大(附有屏幕截图)。
Text(
modifier = Modifier.padding(25.dp).fillMaxSize(),
text = "Park Street, San jose, California, United States ark Street, San jose, California, United States Park Street, San jose, California, United States ark Street, San jose, California, United States Park Street, San jose, California, United States ark Street, San jose, California, United States ",
fontWeight = FontWeight.Normal,
fontSize = 11.sp,
color = DarkBlue1,
overflow = TextOverflow.Ellipsis,
)
还发现,如果我们将其作为预览版运行,它可以在模拟器中运行,但不能作为完整的应用程序运行
我找到了解决方案。 该问题是由于样式标签中的 includeFontPadding 参数造成的。更新如下代码来解决它。使用与问题相同的文本视图
Text(
modifier = Modifier.padding(25.dp).fillMaxSize(),
text = "Park Street, San jose, California, United States ark Street, San jose, California, United States Park Street, San jose, California, United States ark Street, San jose, California, United States Park Street, San jose, California, United States ark Street, San jose, California, United States ",
fontWeight = FontWeight.Normal,
fontSize = 11.sp,
color = DarkBlue1,
overflow = TextOverflow.Ellipsis,
platformStyle = PlatformTextStyle( includeFontPadding = false )
)