Reputation:
Is it possible to use transition drawable for Actionbar and how? I should use an xml like:
<xml version="1.0" encoding="utf-8"/>
<transition xmlns:android="http://schemas.android.com/apk/res/android"/>
<item android:drawable="@drawable/first_image"/>
<item android:drawable="@drawable/second_image"/>
</transition>
but how I continue from here?
Upvotes: 1
Views: 315
Reputation: 602
Yes, it is possible.
You can do it without XML, just create a TransitionDrawable
in your code:
Drawable firstImage = getDrawable(R.drawable.first_image);
Drawable secondImage = getDrawable(R.drawable.secondImage);
TransitionDrawable transition = new TransitionDrawable(new Drawable[] {
firstImage, secondImage});
After that set this transition as background to your ActionBar:
getSupportActionBar().setBackgroundDrawable(transition);
And start the transition:
transition.startTransition(1000);
Also you can set this transition as background to Toolbar.
Upvotes: 0