dimsuz
05/27/2021, 5:24 PMButton {
Text(...)
Icon() // 24x24dp
}
Altough button content is a RowScope
with verticalArrangement = CenterVertical
, Text
seems to not be vertically centered, you can see it's shifted down compared to Icon. Why is that and how can I fix this?Chris Sinco [G]
05/27/2021, 5:40 PMButton(
onClick = { },
modifier = Modifier
.height(72.dp)
.fillMaxWidth(),
shape = MaterialTheme.shapes.medium
) {
Text("Log in".toUpperCase())
Icon(
imageVector = Icons.Default.Face,
contentDescription = null
)
}
dimsuz
05/27/2021, 7:00 PMprivate val Roboto = FontFamily(
Font(R.font.roboto_medium, FontWeight.Medium),
)
@Composable
fun CustomButton(
text: String,
) {
androidx.compose.material.Button(
onClick = { },
modifier = Modifier.heightIn(min = 56.dp).fillMaxWidth(),
shape = MaterialTheme.shapes.medium,
) {
Text(
text = text,
textAlign = TextAlign.Center,
style = TextStyle(
fontFamily = Roboto,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
)
)
Icon(
Icons.Filled.Face,
contentDescription = null
)
}
}
@Preview(showBackground = true, widthDp = 360)
@Composable
fun StoryBookButtons1() {
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
CustomButton(
text = "A very very very long button not fitting one one line",
)
CustomButton(
text = "Continue",
)
}
}
val Roboto
)Continue
becomes v-centered again.
If you use another font (from MaterialTheme), bug is not reproducable eitherChris Sinco [G]
05/27/2021, 8:01 PMdimsuz
05/27/2021, 9:24 PMChris Sinco [G]
05/27/2021, 11:23 PM