How to center item inside the surface in jet pack compose
@Composable
fun RoundedShapeWithIconCenter(
modifier: Modifier = Modifier,
parentSize : Dp,
parentBackgroundColor : Color,
childPadding : Dp,
icon : Painter,
iconSize : Dp,
iconTint : Color,
elevation : Dp = 0.dp,
isTextOrIcon : Boolean = false,
insideText : String = "",
insideTextColor : Color = colorResource(id = R.color.black),
fontSize: TextUnit = 16.sp
) {
Surface(
modifier = modifier.size(parentSize),
shape = RoundedCornerShape(50),
color = parentBackgroundColor,
elevation = elevation,
) {
if (isTextOrIcon) {
CommonText(value = insideText, fontSize = fontSize, color = insideTextColor, textAlign = TextAlign.Center)
} else {
Icon(painter = icon, contentDescription = "Back Arrow", modifier = Modifier
.size(iconSize)
.padding(childPadding), tint = iconTint)
}
}
}
In image the circular black color shape is Surface and Go is Text inside Surface. I want to center the Go text inside the Surface. If I replace text with icon it center perfectly
Thanks in advance