I found this question really interesting, so I decided to find a solution (so forgive me if this solution is not as optimal as it may be, this is just an example to show the way).
After some research, I decided to use the Android timer : the global idea is to have a timer that updates the actionBar background at a regular interval (so to create the fade_in effect, I just need to keep the same background and change its opacity).
Here is my implementation:
First: my custom class, which will do most of the work:
public class ToolbarAnimator { private final static String TAG = ToolbarAnimator.class.getSimpleName(); private final int ALPHA_MAX = 255;
When you have this class, you can start the animation from any activity or fragment:
@Override public boolean onCreateOptionsMenu(Menu menu) {
UPDATE:
I made an example application that implements much more functions (for example, you can choose fade_in or fade_out), you can find the source code here .
source share