Expand/Collapse Lollipop toolbar animation (Telegram app)

Edit : Since the release of the Android Design support library, there’s an easier solution. Check joaquin’s answer — Here’s how I did it, there probably are many other solutions but this one worked for me. First of all, you have to use a Toolbar with a transparent background. The expanding & collapsing Toolbar is … Read more

How to reverse the direction of marquee of a TextView

I figured out a very simple and easy way to do this. I made a marquee effect to move in both directions depending on our selection. So, here is the trick: I used a TextView inside a HorizontalScrollView. I controlled its scrolling in a programmatic way. I got length of text using: scroll_pos = (int)myTextView.getLayout().getLineWidth(0); … Read more

How to play GIF in android

2017 UPDATED ANSWER To play GIF in android use Glide library to load any image or GIF. Glide.with(context) .load(YOUR_GIF) .into(YOUR_IMAGE_VIEW); Use Glide to load normal images, images from server or even to load GIF as well. Also have a look at Picasso android image loading library which is similar to Glide but as of now(16 … Read more

Pop the fragment backstack without playing the Pop-Animation

So Warpzit was on the right track, he just didn’t address your specific issue too well. I came across the exact same issue and here is how I solved it. First I created a static boolean variable (for simplicity’s sake, lets put it in the FragmentUtils class)… public class FragmentUtils { public static boolean sDisableFragmentAnimations … Read more

Android translate animation – permanently move View to new position using AnimationListener

I usually prefer to work with deltas in translate animation, since it avoids a lot of confusion. Try this out, see if it works for you: TranslateAnimation anim = new TranslateAnimation(0, amountToMoveRight, 0, amountToMoveDown); anim.setDuration(1000); anim.setAnimationListener(new TranslateAnimation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void … Read more

swap fragment in an activity via animation

Old questiion and you probably already figured it out, but for future reference: here’s what you use to set a custom animation when you replace a fragment via code: FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right); ft.replace(R.id.fragment_container, newFragment, “fragment”); // Start the animated transition. ft.commit(); Here is an example of the slide_in_left animation: <?xml version=”1.0″ encoding=”utf-8″?> … Read more

Performing action after fragment transaction animation is finished

The Animators that @nmw implements in his answer were added in API Level 11 and will not work with Fragments as implemented by the Android support library. To listen to Fragment animation events, I extended the support library’s Fragment class and overrode onCreateAnimation, attaching a custom AnimationListener to the returned Animation object: public class MyFragment … Read more

Android make animated video from list of images

Android do not support for AWT’s BufferedBitmap nor AWTUtil, that is for Java SE. Currently the solution with SequenceEncoder has been integrated into jcodec’s Android version. You can use it from package org.jcodec.api.SequenceEncoder. Here is the solution for generating MP4 file from series of Bitmaps using jcodec: try { File file = this.GetSDPathToFile(“”, “output.mp4”); SequenceEncoder … Read more