Kevin Worth
09/07/2023, 8:55 PMText
has a different font size. Is this not possible?
Row(verticalAlignment = <http://Alignment.Top|Alignment.Top>) {
Text(
text = "${it.toInt()}",
style = MaterialTheme.typography.headlineMedium.merge(
TextStyle(
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(
alignment = <http://LineHeightStyle.Alignment.Top|LineHeightStyle.Alignment.Top>,
trim = LineHeightStyle.Trim.FirstLineTop
)
)
),
)
Text(
text = "°F",
style = MaterialTheme.typography.bodyLarge.merge(
TextStyle(
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(
alignment = <http://LineHeightStyle.Alignment.Top|LineHeightStyle.Alignment.Top>,
trim = LineHeightStyle.Trim.FirstLineTop)
)
),
)
}
Here’s the unexpected resulting preview:Kevin Worth
09/07/2023, 8:57 PMromainguy
09/07/2023, 10:01 PMText()
items?Kevin Worth
09/07/2023, 10:05 PMKevin Worth
09/07/2023, 10:06 PMKevin Worth
09/07/2023, 10:11 PMincludeFontPadding
set to false
and using Trim.firstLineTop
, there is still some amount of padding, where the characters don’t make it quite all the way to the top of their container. At least that’s how it appears to me given the preview. No?romainguy
09/07/2023, 10:14 PMKevin Worth
09/08/2023, 11:51 AMRow(verticalAlignment = Alignment.CenterVertically) {
Text(
text = "${it.toInt()}",
style = MaterialTheme.typography.headlineMedium
)
Text(
text = "°F",
style = MaterialTheme.typography.bodyLarge.merge(
TextStyle(
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(
alignment = <http://LineHeightStyle.Alignment.Top|LineHeightStyle.Alignment.Top>,
trim = LineHeightStyle.Trim.FirstLineTop
)
)
),
)
}
I get the feeling I might be getting lucky, but if someone knows otherwise, I’d love to know what we can point to that demonstrates this really is the proper way to do it if in fact this will work no matter how the fonts/sizes change…?Zach Klippenstein (he/him) [MOD]
09/08/2023, 9:33 PMromainguy
09/08/2023, 9:54 PMromainguy
09/08/2023, 9:55 PMCanvas
where you can control positioning down to the pixelZach Klippenstein (he/him) [MOD]
09/08/2023, 10:02 PMHalil Ozercan
09/09/2023, 8:58 PMromainguy
09/09/2023, 9:39 PMHalil Ozercan
09/09/2023, 10:31 PMColton Idle
09/11/2023, 1:48 AMromainguy
09/11/2023, 1:52 AM