Skip to content

[LinearProgressIndicator,MaterialContainerTransform] LinearProgressIndicator disappear #4969

@AttemptD

Description

@AttemptD

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<ContentFrameLayout>(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions