![](https://camo.githubusercontent.com/87e2ffb376b4a60f42656b3a6b5a05b235b208285af9f3f16123171558f30011/68747470733a2f2f76656c6f672e76656c63646e2e636f6d2f696d616765732f776f726b73706163652f706f73742f32343261663965382d373762652d343332662d623166332d3731656666323931623738312f616e64726f69642d6a65747061636b2d6865616465722e706e67)
Arrangement.Top
Arrangement.Center
Arrangement.Bottom
li> Arrangement.SpaceBetween
Arrangement.SpaceAround
Arrangement.SpaceEvenly
- horizontalArrangement
- verticalAlignment
border / offset
fillMaxWidth
fillMaxSize
RoundCornerShape
elevation
painter
contentScale
contentAlignment
Brush.verticalGradient / startY
fontFamily
buildAnnotatedString
withStyle / append
TextDecoration
TextField / label
onValueChange
scafooldState / append
showSnackbar
itemsIndex / items
why have to use LazyColumn
scrollState
ConstrainSet ex) greenBox / redBox
createHorizontalChain
ConstrainLayout( constrainst, modifier= ~~)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val constraints = ConstraintSet {
val greenBox = createRefFor("greenBox")
val redBox = createRefFor("redBox")
// val guildline= createGuidelineFromTop(0.5f)
constrain(greenBox) {
// top.linkTo(guildline)
top.linkTo(parent.top)
start.linkTo(parent.start)
width = Dimension.value(100.dp)
height = Dimension.value(100.dp)
}
constrain(redBox) {
top.linkTo(parent.top)
start.linkTo(greenBox.end)
end.linkTo(parent.end)
width = Dimension.value(100.dp)
height = Dimension.value(100.dp)
}
createHorizontalChain( greenBox, redBox, chainStyle = ChainStyle.Packed)
}
ConstraintLayout(constraints, modifier = Modifier.fillMaxWidth()){
Box(modifier = Modifier
.background(Color.Green)
.layoutId("greenBox"))
Box(modifier = Modifier
.background(Color.Red)
.layoutId("redBox"))
}
}
}
}
![แแ
ณแแ
ณแ
แ
ตแซแแ
ฃแบ 2022-05-28 แแ
ฉแแ
ฅแซ 12 11 35](https://user-images.githubusercontent.com/70245821/170727921-d0d4fb8c-f64c-42b3-b65e-476a8f23a982.png)
animationDpAsState
animationSeec / infiniteRepeatable / repeatMode = RepearMode.Reverse
ConstrainLayout( constrainst, modifier= ~~)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var sizeState by remember { mutableStateOf(200.dp) }
val size by animateDpAsState(
targetValue = sizeState,
tween(
durationMillis = 1000
)
)
val inifiniteTransition = rememberInfiniteTransition()
val color by inifiniteTransition.animateColor(
initialValue = Color.Red,
targetValue = Color.Green,
animationSpec = infiniteRepeatable(
tween(durationMillis = 2000),
repeatMode = RepeatMode.Reverse
)
)
Box(
modifier = Modifier
.size(size)
.background(color),
contentAlignment = Alignment.Center
) {
Button(onClick = {
sizeState += 50.dp
}) {
Text(text = "Increase Size")
}
}
}
}
}
![แแ
ชแแ
งแซ-แแ
ตแ
แ
ฉแจ-2022-05-29-แแ
ฉแแ
ฎ-4 24 50](https://user-images.githubusercontent.com/70245821/170857191-06339f7c-a1ff-4f91-aa52-8067fa715b79.gif)
animationDpAsState
drawArc / LaunchedEffect
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Box(contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
){
CircularProgressBar(percentage = 0.8f, number = 100)
}
}
}
}
@Composable
fun CircularProgressBar(
percentage: Float,
number: Int,
fontSize: TextUnit = 28.sp,
radius: Dp = 50.dp,
color: Color = Color.Green,
strokeWidth: Dp = 8.dp,
animDuration: Int = 2000,
animDelay: Int = 0
) {
var animationPlayed by remember {
mutableStateOf(false)
}
var curPercentage = animateFloatAsState(
targetValue = if(animationPlayed) percentage else 0f,
animationSpec = tween(
durationMillis = animDuration,
delayMillis = animDelay
)
)
LaunchedEffect(key1 = true){
animationPlayed = true
}
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.size(radius * 2f)
) {
Canvas(modifier = Modifier.size(radius * 2f) )
{
drawArc(
color = color,
-90f,
360 * curPercentage.value,
useCenter = false,
style = Stroke(strokeWidth.toPx(), cap = StrokeCap.Round )
)
}
Text(
text = (curPercentage.value * number).toInt().toString(),
color = Color.Black,
fontSize = fontSize,
fontWeight = FontWeight.Bold
)
}
}
![แแ
ชแแ
งแซ-แแ
ตแ
แ
ฉแจ-2022-05-29-แแ
ฉแแ
ฎ-5 48 40](https://user-images.githubusercontent.com/70245821/170859957-3598521d-1d70-4cf9-8ee9-a303c52c38b5.gif)