Skip to content

Simple Animation with Jetpack Compose | Animation run unexpected way #71

Open
@Jaehwa-Noh

Description

@Jaehwa-Noh

URL of codelab
Codelab

In which task and step of the codelab can this issue be found?
7 (Optional) Experiment with other animations - 3

Describe the problem
Background color animation does not work I'd expected.
Android20231122_222433

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions
Android Studio version: Android Studio Giraffe 2022.3.1 Patch 4
API version of the emulator: 34

Additional information
Include screenshots if they would be useful in clarifying the problem.

Suggestion

Need to change modifier chain order.
This code change

 Card(modifier = modifier) {
        Column(
            modifier = Modifier
                .animateContentSize(
                    animationSpec = spring(
                        dampingRatio = Spring.DampingRatioNoBouncy,
                        stiffness = Spring.StiffnessMedium
                    )
                )
                .background(color = color)   // <----
        ) { }

to this.

 Card(modifier = modifier) {
        Column(
            modifier = Modifier
                .background(color = color)   // <----
                .animateContentSize(
                    animationSpec = spring(
                        dampingRatio = Spring.DampingRatioNoBouncy,
                        stiffness = Spring.StiffnessMedium
                    )
                )
        ) { }

Result

Android20231122_224300

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions