Fixed inconsistent transitions
This commit is contained in:
parent
a25c80a9bc
commit
f9c918234d
6 changed files with 83 additions and 4 deletions
|
@ -18,6 +18,7 @@ import android.os.Bundle
|
|||
import android.view.*
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.updatePadding
|
||||
|
@ -48,8 +49,6 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = FragmentMainRecyclerBinding.bind(view)
|
||||
enterTransition = MaterialFadeThrough()
|
||||
exitTransition = MaterialFadeThrough()
|
||||
postponeEnterTransition()
|
||||
view.doOnPreDraw { startPostponedEnterTransition() }
|
||||
|
||||
|
@ -61,6 +60,10 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
setupToolbar()
|
||||
}
|
||||
|
||||
fun toolbar(): Toolbar {
|
||||
return binding.toolbar
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
binding.toolbar.setNavigationOnClickListener {
|
||||
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true).addTarget(requireView())
|
||||
|
|
|
@ -53,8 +53,6 @@ class HomeFragment :
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
_binding = getBinding(PreferenceUtil.isHomeBanner, view)
|
||||
enterTransition = MaterialFadeThrough()
|
||||
exitTransition = MaterialFadeThrough()
|
||||
mainActivity.setSupportActionBar(binding.toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
setStatusBarColorAuto(view)
|
||||
|
|
30
app/src/main/res/animator/nav_default_enter_anim.xml
Normal file
30
app/src/main/res/animator/nav_default_enter_anim.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="0"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
9
app/src/main/res/animator/nav_default_exit_anim.xml
Normal file
9
app/src/main/res/animator/nav_default_exit_anim.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
30
app/src/main/res/animator/nav_default_pop_enter_anim.xml
Normal file
30
app/src/main/res/animator/nav_default_pop_enter_anim.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleX"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="scaleY"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.92"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="210"
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="90"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="1.0" />
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="0"
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
9
app/src/main/res/animator/nav_default_pop_exit_anim.xml
Normal file
9
app/src/main/res/animator/nav_default_pop_exit_anim.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:duration="90"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:propertyName="alpha"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0" />
|
||||
</set>
|
Loading…
Reference in a new issue