接收 animationSpec 和 finishedListener 两个参数
Created
November 21, 2021 13:04
-
-
Save hyoban/f4bd608cb1a36a021a25cfdae2d696e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.animation.animateContentSize | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.size | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.mutableStateOf | |
import androidx.compose.runtime.remember | |
import androidx.compose.runtime.setValue | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.unit.dp | |
@Composable | |
fun AnimateContentSizeExample() { | |
Box( | |
modifier = Modifier.fillMaxSize() | |
) { | |
var size by remember { mutableStateOf(50.dp) } | |
Box( | |
modifier = Modifier | |
.align(Alignment.Center) | |
.animateContentSize() | |
.size(size) | |
.background(Color.Blue) | |
.clickable { | |
size += 50.dp | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment