Jast Lai
11/24/2021, 8:47 AMclass MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Greeting("Text")
}
lifecycleScope.launch {
delay(1000)
repeat(100) {
delay(10)
animationPoint.value = animationPoint.value + 1
}
}
}
}
var animationPoint = mutableStateOf(0)
@Composable
fun Greeting(aText: String) {
Surface(
modifier = Modifier.offset(
x = animationPoint.value.dp
)
) {
Column {
repeat(40) {
Text("Text")
}
}
}
}
this will make those Texts from left to right. It seem smooth and without any question.
But if I change like this Text content to parameter.
@Composable
fun Greeting(aText: String) {
Surface(
modifier = Modifier.offset(
x = animationPoint.value.dp
)
) {
Column {
repeat(40) {
Text(aText)
}
}
}
}
It will feel lag and obviously has drop some frame.
I wonder what difference between those two method ?
And If I don't wanna drop frame, How should I do ?Tolriq
11/24/2021, 9:01 AMJast Lai
11/24/2021, 9:20 AMTolriq
11/24/2021, 9:25 AMJast Lai
11/24/2021, 9:29 AMTolriq
11/24/2021, 9:31 AMJast Lai
11/24/2021, 9:33 AMTolriq
11/24/2021, 9:38 AMJast Lai
11/24/2021, 9:40 AM