sen kumar
03/05/2021, 1:18 AMDeepak Gahlot
03/05/2021, 3:19 AMDoris Liu
03/05/2021, 4:20 AMDeepak Gahlot
03/05/2021, 4:21 AMDeepak Gahlot
03/05/2021, 4:31 AMDeepak Gahlot
03/05/2021, 4:54 AMDeepak Gahlot
03/05/2021, 4:54 AMDoris Liu
03/05/2021, 4:55 AMDoris Liu
03/05/2021, 5:49 AMAnimatedVisibility
didn't support child content size change. So in this nested AnimatedVisibility
case, the inner one adds more content but the outer one didn't change its size to accommodate that. The good news is we added support for child content size change yesterday: https://issuetracker.google.com/172359738. Just verified the repro case with the fix, it's working as expected (i.e. the same final result as jump cut). The fix will be in the next release (going out next week).Deepak Gahlot
03/05/2021, 8:57 AMDeepak Gahlot
03/05/2021, 8:57 AMfun ExpandableContent(
questions: ArrayList<ItemsItem>,
qResponse: Response,
visible: Boolean = true,
initialVisibility: Boolean = false,
questionnaireViewModel: QuestionnaireViewModel,
topItemId: String, topItemLabel: String
) {
val enterFadeIn = remember {
fadeIn(
animationSpec = TweenSpec(
durationMillis = FADE_IN_ANIMATION_DURATION,
)
)
}
val enterExpand = remember {
expandVertically(animationSpec = tween(EXPAND_ANIMATION_DURATION))
}
val exitFadeOut = remember {
fadeOut(
animationSpec = TweenSpec(
durationMillis = FADE_OUT_ANIMATION_DURATION,
easing = LinearOutSlowInEasing
)
)
}
val exitCollapse = remember {
shrinkVertically(animationSpec = tween(COLLAPSE_ANIMATION_DURATION))
}
AnimatedVisibility(
visible = visible,
initiallyVisible = initialVisibility,
enter = enterFadeIn,
exit = exitCollapse + exitFadeOut
)
// if(visible)
{
Divider(color = colorResource(id = R.color.gray9), thickness = 1.dp)
Column(
modifier = Modifier
.fillMaxWidth()
.padding(top = 10.dp, start = 20.dp, end = 12.dp, bottom = 10.dp)
) {
var questionnaireChildSectionFieldsTable: Table<String, String, ItemsItem> =
HashBasedTable.create<String, String, ItemsItem>()
for (question in questions) {
LoggingService.instance.logDebug(
TAG,
"ExpandableContent: ******* " + question.qualifiedNumber
)
ViewItem(
question = question,
qResponse = qResponse,
questionnaireChildSectionFieldsTable
)
CallQuestionTypeViews(question = question, qResponse)
}
}
}
}
Deepak Gahlot
03/05/2021, 8:58 AMval enterExpand = remember {
expandVertically(animationSpec = tween(EXPAND_ANIMATION_DURATION))
Deepak Gahlot
03/05/2021, 8:59 AMDeepak Gahlot
03/05/2021, 9:01 AMDeepak Gahlot
03/05/2021, 9:01 AMDeepak Gahlot
03/05/2021, 9:01 AM@Stable
@ExperimentalAnimationApi
fun expandVertically(
expandFrom: Alignment.Vertical = Alignment.Bottom,
initialHeight: (fullHeight: Int) -> Int = { 0 },
animationSpec: FiniteAnimationSpec<IntSize> = spring(),
clip: Boolean = true
): EnterTransition {
return expandIn(
expandFrom.toAlignment(),
{ IntSize(it.width, initialHeight(it.height)) },
animationSpec,
clip
)
}
Doris Liu
03/05/2021, 7:24 PMbut because i'm also using a nested expand/collapse view , the height is gives to the Card initially is correct, but then the nested component is expanded the height of thr Card remains the same.Yes, that's what the issue linked above is referring to.
AnimatedVisibility
has a size change animation (if expand/shrink is used). The size of the Layout
(owned by AnimatedVisibility) is read from that size change animation, which didn't update its value once the enter transition is finished. That's why when you don't use shrink/expand, you don't hit the issue (because no size change animation is created).
So the question i have is, Can we make the initialHeight in the expandVertically to change with the nested componentIf I understand the intention correctly, this request is already addressed by the fix. New behavior after the fix: once the enter transition is finished, the outter
AnimatedVisibility
will be snapping its size to whatever its content reports. In the case of nested AV, as the inner one expands it will continuously influence the content size of the outer one. The outer one will appear to be animating as a result.
If you'd like to play with tip of tree androidx-main, I'd love to know how the new behavior works for you. 🙂