You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With implementation 'com.github.alexjlockwood:kyrie:0.2.0'
I have run into an issue where the ImageViews that have a KyrieDrawable disappear when running a Transition through TransitionManager.beginDelayedTransition(). To better observe this behavior (bug?) I have recorded the following two gifs:
With val drawable = KyrieDrawable.create(context, resId)
With val drawable = AppCompatResources.getDrawable(context, resId):
As you can see, when using Kyrie, the image disappears before the transition is done, but that doesn't happen using AndroidX's vector drawables.
The full code : MainActivity.kt
class MainActivity : AppCompatActivity() {
private lateinit var container: FrameLayout
private lateinit var firstView: View
private lateinit var secondView: View
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
container = findViewById(R.id.container)
val inflater = LayoutInflater.from(this)
firstView = inflater.inflate(R.layout.view_one, container, false) as ViewGroup
secondView = inflater.inflate(R.layout.view_two, container, false) as ViewGroup
firstView.findViewById<ImageView>(R.id.image).setVectorDrawable(R.drawable.ic_android_black_24dp)
firstView.findViewById<Button>(R.id.button).setOnClickListener(::onClick)
secondView.findViewById<ImageView>(R.id.image).setVectorDrawable(R.drawable.ic_android_black_24dp)
secondView.findViewById<Button>(R.id.button).setOnClickListener(::onClick)
container.addView(firstView)
}
fun onClick(view: View) {
val transition = TransitionSet().apply {
duration = 1000
addTransition(Slide(Gravity.END).apply {
mode = Slide.MODE_IN
interpolator = LinearInterpolator()
})
addTransition(Slide(Gravity.START).apply {
mode = Slide.MODE_OUT
interpolator = LinearInterpolator()
})
setMatchOrder(Transition.MATCH_INSTANCE)
}
TransitionManager.beginDelayedTransition(container, transition)
if (container.getChildAt(0) == firstView) {
container.removeAllViews()
container.addView(secondView)
} else {
container.removeAllViews()
container.addView(firstView)
}
}
fun ImageView.setVectorDrawable(@DrawableRes resId: Int) {
// val drawable = KyrieDrawable.create(context, resId)
val drawable = AppCompatResources.getDrawable(context, resId)
setImageDrawable(drawable)
}
With
implementation 'com.github.alexjlockwood:kyrie:0.2.0'
I have run into an issue where the ImageViews that have a
KyrieDrawable
disappear when running aTransition
throughTransitionManager.beginDelayedTransition()
. To better observe this behavior (bug?) I have recorded the following two gifs:With
![KyrieDrawable](https://camo.githubusercontent.com/ac4d4943086abb99710a97cbee12bfc37c3510c37c26ad21d6b57c9eca7f3644/68747470733a2f2f7468756d62732e6766796361742e636f6d2f4a65616c6f7573436f6f7065726174697665446f6c7068696e2e77656270)
val drawable = KyrieDrawable.create(context, resId)
With
![AndroidX VectorDrawable](https://camo.githubusercontent.com/01cffcf5a8ec22685ec080990514125fca06a5c0326b48699d08e302c47e8bae/68747470733a2f2f7468756d62732e6766796361742e636f6d2f436c6f7365496d7065727475726261626c65426f76696e652e77656270)
val drawable = AppCompatResources.getDrawable(context, resId)
:As you can see, when using Kyrie, the image disappears before the transition is done, but that doesn't happen using AndroidX's vector drawables.
The full code :
MainActivity.kt
activity_main.xml
view_one.xml
view_two.xml
ic_android_black_24.dp.xml
The text was updated successfully, but these errors were encountered: