Ink
09/22/2021, 9:19 PMdefaultMinSize
to e.g. 40.dp it looks good but I don't want that big
Code in thread:Chris Johnson
09/22/2021, 9:31 PMColton Idle
09/22/2021, 9:37 PMChris Sinco [G]
09/22/2021, 9:40 PMcontentAlignment = Alignment.Center
on the Box
ComposableInk
09/22/2021, 9:42 PMBox(contentAlignment= Alignment.Center,
modifier = Modifier
.background(Color.Black, shape = CircleShape)
.layout(){ measurable, constraints ->
val placeable = measurable.measure(constraints)
//get the current max dimension to assign width=height
val currentHeight = placeable.height
var heightCircle = currentHeight
if (placeable.width > heightCircle)
heightCircle = placeable.width
//assign the dimension and the center position
layout(heightCircle, heightCircle) {
// Where the composable gets placed
placeable.placeRelative(0, (heightCircle-currentHeight)/2)
}
}) {
Text(
text = questionIndex.toString(),
textAlign = TextAlign.Center,
color = Color.White,
modifier = Modifier.defaultMinSize(20.dp) //Use a min size for short text.
)
}
Text(
text = question.question,
fontFamily = DefaultFont,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
color = Color(0xFF1E1E1E),
modifier = Modifier.padding(start = 10.dp)
)
}
Ink
09/22/2021, 9:43 PMInk
09/22/2021, 9:44 PMCanvas(modifier = Modifier.size(100.dp), onDraw = {
drawCircle(color = Color.Red)
})
Chris Sinco [G]
09/22/2021, 9:46 PMInk
09/22/2021, 9:48 PMChris Sinco [G]
09/22/2021, 9:50 PMChris Sinco [G]
09/22/2021, 9:50 PMChris Sinco [G]
09/22/2021, 9:51 PM@Preview
@Composable
fun SlackTest() {
Box(
contentAlignment= Alignment.Center,
modifier = Modifier
.background(Color.Black, shape = CircleShape)
.size(20.dp)
) {
Text(
text = "1",
textAlign = TextAlign.Center,
color = Color.White,
)
}
}
produces thisInk
09/22/2021, 9:56 PMChris Sinco [G]
09/22/2021, 9:56 PMCanvas
to do it, you can use drawText
Jeff
09/23/2021, 12:59 PMChris Sinco [G]
09/23/2021, 6:33 PMTin Tran
09/24/2021, 8:28 AM