material-components / material-components/material-components-android

[LinearProgressIndicator,MaterialContainerTransform] LinearProgressIndicator disappear

Open
#4,969 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Transition Widget: ProgressIndicator
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:** When I use MaterialContainerTransform to open an activity, if there is a LinearProgressIndicator component in the activity, LinearProgressIndicator will disappear and cannot be displayed in the interface. It must be hidden before being displayed at the start and end settings of MaterialContainerTransform animation listening, and the isIndeterminate state of LinearProgressIndicator needs to be changed in order to be displayed properly. This experience is very unsatisfactory and If you don't set it at the beginning and end of the animation, you need to lock the device first and then unlock it to open the screen, and the progress bar will also appear

**Source code:**

```
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
val content = findViewById(android.R.id.content)
content.transitionName = "shared_element_end_root"
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
window.sharedElementEnterTransition = buildContainerTransform(true)
window.sharedElementReturnTransition = buildContainerTransform(false)

private fun buildContainerTransform(entering: Boolean): MaterialContainerTransform {
val transform = MaterialContainerTransform().apply {
addTarget(android.R.id.content)
duration = if (entering) 400 else 390
interpolator = FastOutSlowInInterpolator()
setPathMotion(MaterialArcMotion())
endContainerColor = MaterialColors.getColor(
findViewById(android.R.id.content), com.google.android.material.R.attr.colorSurface
)
addListener(object : TransitionListener {
override fun onTransitionStart(p0: Transition?) {
if (!entering) {
binding.main.setGone()
} else {
binding.playBtn.setGone()
binding.historyProgress.setGone()
binding.historyProgress.post {
binding.historyProgress.isIndeterminate = true
}
}
}

override fun onTransitionEnd(p0: Transition?) {
if (entering) {
binding.historyProgress.post {
binding.historyProgress.isIndeterminate = false
}
AnimationTools.instance.fadeIn(
binding.playBtn
)
AnimationTools.instance.fadeIn(
binding.historyProgress
)
binding.content.scrollTo(0, 0)
episodeAdapter?.notifyDataSetChanged()
}
}

override fun onTransitionCancel(p0: Transition?) {
}

override fun onTransitionPause(p0: Transition?) {
}

override fun onTransitionResume(p0: Transition?) {
}

})
}
return transform
}
```

**Android API version:**
android 16

**Material Library version:**
1.12.0 - 1.14.0-alpha06

**Device:**
samsung 23 ,pixel 8pro

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the supplied MaterialContainerTransform activity-transition setup as the reproduction entry point, with a LinearProgressIndicator on the destination activity, and verify the behavior on the listed Android versions and devices. Trace the transition lifecycle and progress-indicator state around the reported disappearance; done means the indicator remains displayable without manually hiding it or changing isIndeterminate before and after the animation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.