MotionLayout not adjusting height dynamically during collapse/expand Animation jetpack compose

i am trying to create a list item in jetpack compose.

here is what i have done so far:

@OptIn(ExperimentalMotionApi::class)
@Preview(showBackground = true)
@Composable
fun Item2MotionLayout(progress: Float = 0f) {

    val context = LocalContext.current

    val sceneFile = R.raw.motion_live

    val motionSceneContent = remember(sceneFile) {
        context.resources
            .openRawResource(sceneFile)
            .readBytes()
            .decodeToString()
    }

    val motionScene = MotionScene(motionSceneContent)


    MotionLayout(
        motionScene = motionScene,
        progress = progress,
        modifier = Modifier
            .fillMaxWidth()
            .wrapContentHeight()
            .background(Color.Yellow)


    ) {
        Image(
            modifier = Modifier
                .size(48.dp)
                .clip(CircleShape)
                .layoutId("icon"),
            painter = painterResource(R.drawable.person),
            contentDescription = null,
            contentScale = ContentScale.Crop
        )
        Text("Ali Asjad", modifier = Modifier.layoutId("title"))

        Text(
            "14-09-2024",
            fontSize = 11.sp,
            modifier = Modifier
                .padding(start = 10.dp)
                .layoutId("date")
        )


        Text(
            stringResource(R.string.lorem),
            maxLines = 2, // Maximum 2 lines
            overflow = TextOverflow.Ellipsis,
            modifier = Modifier
                .layoutId("text")
        )

        Image(
            modifier = Modifier
                .size(50.dp)
                .clip(RoundedCornerShape(0.dp))
                .layoutId("picture"),
            painter = painterResource(R.drawable.person),
            contentDescription = null,
            contentScale = ContentScale.Crop
        )

        Icon(
            imageVector = Icons.Filled.ArrowDropDown,
            modifier = Modifier
                .size(20.dp)
                .layoutId("arrowIcon"),
            contentDescription = null
        )


    }

this is my json file:

 {

  ConstraintSets: {
    start: {
      icon: {
        start: ['parent', 'start'],
        top: ['parent', 'top'],
        bottom: ['parent', 'bottom']
      },
      title: {
        start: ['icon', 'end'],
        top: ['parent', 'top']
      },
      date: {
        start: ['title', 'end'],
        top: ['parent', 'top']

      },
      text: {
        start: ['icon', 'end'],
        end: ['picture', 'start'],
        top: ['title', 'bottom'],
        width: 'spread',


      },
      picture: {
        end: ['arrowIcon', 'start'],
        top: ['parent', 'top']

      },
      arrowIcon: {
        end: ['parent', 'end'],
        top: ['parent', 'top']

      }
    },
    end: {
      icon: {
        start: ['parent', 'start'],
        top: ['parent', 'top'],
        bottom: ['text', 'bottom']
      },
      title: {
        start: ['icon', 'end'],
        top: ['parent', 'top']
      },
      date: {
        start: ['title', 'end'],
        top: ['parent', 'top']

      },
      text: {
        start: ['title', 'start'],
        end: ['arrowIcon', 'start'],
        top: ['title', 'bottom'],
        width: 'spread'
      },
      picture: {
        start: ['icon', 'end'],
        top: ['text', 'bottom'],
        width: 150,
        height: 150,

      },
      arrowIcon: {
        end: ['parent', 'end'],
        top: ['parent', 'top']

      }
    }
  },


  Transitions: {
    default: {
      from: 'start',
      to: 'end',
      KeyFrames: {
        KeyAttributes: [
          {
            target: ['picture'],
//            frames: [0,25,50,75, 100],
          }

        ],

      }
    }
  }
}

I’m facing an issue where MotionLayout is not adjusting its height correctly in the collapsed state. The background of the MotionLayout is yellow, and it’s taking the height of its end state even in the start state. I want the height to increase gradually with the animation as it expands, with the height dynamically adjusting according to the content.

Is this the correct approach for implementing this layout, or am I missing something? How can I ensure that the MotionLayout properly wraps its height before the animation starts?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

MotionLayout not adjusting height dynamically during collapse/expand Animation jetpack compose

i am trying to create a list item in jetpack compose.

here is what i have done so far:

@OptIn(ExperimentalMotionApi::class)
@Preview(showBackground = true)
@Composable
fun Item2MotionLayout(progress: Float = 0f) {

    val context = LocalContext.current

    val sceneFile = R.raw.motion_live

    val motionSceneContent = remember(sceneFile) {
        context.resources
            .openRawResource(sceneFile)
            .readBytes()
            .decodeToString()
    }

    val motionScene = MotionScene(motionSceneContent)


    MotionLayout(
        motionScene = motionScene,
        progress = progress,
        modifier = Modifier
            .fillMaxWidth()
            .wrapContentHeight()
            .background(Color.Yellow)


    ) {
        Image(
            modifier = Modifier
                .size(48.dp)
                .clip(CircleShape)
                .layoutId("icon"),
            painter = painterResource(R.drawable.person),
            contentDescription = null,
            contentScale = ContentScale.Crop
        )
        Text("Ali Asjad", modifier = Modifier.layoutId("title"))

        Text(
            "14-09-2024",
            fontSize = 11.sp,
            modifier = Modifier
                .padding(start = 10.dp)
                .layoutId("date")
        )


        Text(
            stringResource(R.string.lorem),
            maxLines = 2, // Maximum 2 lines
            overflow = TextOverflow.Ellipsis,
            modifier = Modifier
                .layoutId("text")
        )

        Image(
            modifier = Modifier
                .size(50.dp)
                .clip(RoundedCornerShape(0.dp))
                .layoutId("picture"),
            painter = painterResource(R.drawable.person),
            contentDescription = null,
            contentScale = ContentScale.Crop
        )

        Icon(
            imageVector = Icons.Filled.ArrowDropDown,
            modifier = Modifier
                .size(20.dp)
                .layoutId("arrowIcon"),
            contentDescription = null
        )


    }

this is my json file:

 {

  ConstraintSets: {
    start: {
      icon: {
        start: ['parent', 'start'],
        top: ['parent', 'top'],
        bottom: ['parent', 'bottom']
      },
      title: {
        start: ['icon', 'end'],
        top: ['parent', 'top']
      },
      date: {
        start: ['title', 'end'],
        top: ['parent', 'top']

      },
      text: {
        start: ['icon', 'end'],
        end: ['picture', 'start'],
        top: ['title', 'bottom'],
        width: 'spread',


      },
      picture: {
        end: ['arrowIcon', 'start'],
        top: ['parent', 'top']

      },
      arrowIcon: {
        end: ['parent', 'end'],
        top: ['parent', 'top']

      }
    },
    end: {
      icon: {
        start: ['parent', 'start'],
        top: ['parent', 'top'],
        bottom: ['text', 'bottom']
      },
      title: {
        start: ['icon', 'end'],
        top: ['parent', 'top']
      },
      date: {
        start: ['title', 'end'],
        top: ['parent', 'top']

      },
      text: {
        start: ['title', 'start'],
        end: ['arrowIcon', 'start'],
        top: ['title', 'bottom'],
        width: 'spread'
      },
      picture: {
        start: ['icon', 'end'],
        top: ['text', 'bottom'],
        width: 150,
        height: 150,

      },
      arrowIcon: {
        end: ['parent', 'end'],
        top: ['parent', 'top']

      }
    }
  },


  Transitions: {
    default: {
      from: 'start',
      to: 'end',
      KeyFrames: {
        KeyAttributes: [
          {
            target: ['picture'],
//            frames: [0,25,50,75, 100],
          }

        ],

      }
    }
  }
}

I’m facing an issue where MotionLayout is not adjusting its height correctly in the collapsed state. The background of the MotionLayout is yellow, and it’s taking the height of its end state even in the start state. I want the height to increase gradually with the animation as it expands, with the height dynamically adjusting according to the content.

Is this the correct approach for implementing this layout, or am I missing something? How can I ensure that the MotionLayout properly wraps its height before the animation starts?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật