本文主要是介绍compose for desktop,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
then 叠加修饰符功能的作用
val reusableModifier = Modifier.fillMaxWidth().background(Color.Red).padding(12.dp)// Append to your reusableModifier
reusableModifier.clickable { /*...*/ }// Append your reusableModifier
otherModifier.then(reusableModifier)
https://developer.aliyun.com/article/1409449
Compose 类型稳定性注解:@Stable & @Immutable
- 主动测量
SubcomposeLayout
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.SubcomposeLayout@Composable
fun DynamicContent() {SubcomposeLayout { constraints ->val placeable = subcompose("MyDynamicComponent") {// 动态创建或更新子组件Box(modifier = Modifier.fillMaxSize()) {// 子组件内容}}.first().measure(constraints)layout(placeable.width, placeable.height) {placeable.placeRelative(0, 0)}}
}
以上先测量宽高再布局
这篇关于compose for desktop的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!