Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices.

Overview

PreLollipopTransition

build status API

Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices.

prelollipopanimation

Download

In your app build.gradle add

dependencies {
    compile 'com.kogitune:pre-lollipop-activity-transition:1.x.x'
}

Download

Code

Activity

Start Activity in first activity.

findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        final Intent intent = new Intent(MainActivity.this, SubActivity.class);
        ActivityTransitionLauncher.with(MainActivity.this).from(v).launch(intent);
    }
});

Receive intent in second activity.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sub);
    ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
}

If you want the exit animation, you can do like this.

private ExitActivityTransition exitTransition;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sub2);
    exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
}
@Override
public void onBackPressed() {
    exitTransition.exit(this);
}

If you want to use startActivityForResult, you should do below.

  1. Use createBundle().
  2. Put Extra to intent.
  3. Call overridePendingTransition after startActivityForResult.
Bundle transitionBundle = ActivityTransitionLauncher.with(MainActivity.this).from(v).createBundle();
intent.putExtras(transitionBundle);
startActivityForResult(intent, REQUEST_CODE);
// you should prevent default activity transition animation
overridePendingTransition(0, 0);

Fragment

Start fragment transition in first fragment.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.support_fragment_start, container, false);
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final EndFragment toFragment = new EndFragment();
            FragmentTransitionLauncher
                    .with(view.getContext())
                    .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
                    .from(view.findViewById(R.id.imageView)).prepare(toFragment);
            getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();
        }
    });
    return v;
}

Start animation in second fragment.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.support_fragment_end, container, false);
    final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this).to(v.findViewById(R.id.fragment_imageView)).start(savedInstanceState);
    exitFragmentTransition.startExitListening();
    return v;
}

If you want to pass argument to second fragment, you should use Fragment#getArguments() after call prepare().

final EndFragment toFragment = new EndFragment();
FragmentTransitionLauncher
        .with(view.getContext())
        .image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))
        .from(view.findViewById(R.id.imageView)).prepare(toFragment);
toFragment.getArguments().putString("stringArgKey", "this is value");
getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();

Sample

image

Contributors

Thanks

Sample Photo Luke Ma https://www.flickr.com/photos/lukema/12499338274/in/photostream/

DevBytes: Custom Activity Animations https://www.youtube.com/watch?v=CPxkoe2MraA

License

This project is released under the Apache License, Version 2.0.

Comments
  • Created file in background

    Created file in background

    see #3

    I was just guessing my assumption at #3 is correct. If not, I will close this pull request.

    ~~Could you give me how to test this library? I haven't build/test this code, yet.~~ Didn't look at circle.yml. I will test this code in my local machine.

    opened by shiraji 20
  • use in Adapter

    use in Adapter

    how to use this library in Adapter? for example my adapter is : public DataAdapter(List<newSMS_class> sms_list_use, RecyclerView recyclerView, Context context) { . . . public void onClick(View view) { final Dialog nagDialog = new Dialog(view.getContext()); nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); nagDialog.setContentView(R.layout.dialog_iamge); ImageView ivPreview = (ImageView) nagDialog.findViewById(R.id.dialog_image); int loader = R.drawable.all_users_avatar; Picasso.with(view.getContext()) .load(Address_class.server_ip() + "UploadUserImage/Avatar/img_" + sms_username.getTag() + ".jpg") .error(loader) .into(ivPreview); ActivityTransitionLauncher.with((Main_Page)mcontext).from(view).launch(nagDialog); nagDialog.show(); }

    tnx

    opened by tellfa 14
  • App crashes on pre-Lollipop

    App crashes on pre-Lollipop

    I ran the app on a samsung device (kitkat) and the app crashed. I cloned the project and launched it on kitkat device the app crashed. I created a new project, went the other way round i.e I added the library in the gradle file I still got the same crash .. Beyond api 19 it seems to work. I tested using the sample and by creating a custom project (and hence importing the library in the gradle file) it works perfectly .....

    The error is on the MainActivity:
    this is the line where the error points to: super.onCreate(savedInstanceState);

    Exception while inflating org.xmlpull.v1.XmlPullParserException: Binary XML file line #17 tag requires viewportHeight > 0

    Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f020052

    Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector

    opened by ClaudeHangui 10
  • Mutiple Views?

    Mutiple Views?

    I'm trying to animate an ImageView and a TextView.

    My code:

    ActivityTransitionLauncher.with(SearchResultsActivity.this).from(v.findViewById(R.id.comic_title)).from(v.findViewById(R.id.thumbnail)).image(bitmap).launch(intent);

    ActivityTransition.with(getActivity().getIntent()).duration(1000).to(tvTitle).to(pvComic).start(null);

    For some reason only the ImageView is animated, the TextView is not.

    opened by tom-anders 7
  • how to listen when animation ends? #36

    how to listen when animation ends? #36

    add enterListener and exitListener in Transition !

        exitTransition = ActivityTransition
                .with(intent)
                .to(findViewById(R.id.sub_imageView))
                .interpolator(new BounceInterpolator())
                .enterListener(new SimpleAnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        Log.e("TAG", "onEnterAnimationStart: ");
                    }
    
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        Log.e("TAG", "onEnterAnimationEnd: ");
                    }
    
                })
                .start(savedInstanceState)
                .exitListener(new SimpleAnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        Log.e("TAG", "onOutAnimationStart: ");
                    }
    
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        Log.e("TAG", "onOutAnimationEnd: ");
                    }
                });
    
    opened by lovejjfg 6
  • how to use StartActivityForResult

    how to use StartActivityForResult

    I have couple of questions

    1. How can I use StartActivityForResult and get the status and return intent in onActivityResult ?
    2. How to pass data via intent and get the data back in the opened Activity ?
    opened by tuhin10 6
  • app crashes after exit animation

    app crashes after exit animation

    Hai. first of of i liked this library very much and working awesome, But my problem is "UNFORTUNATELY , MY APPLICATION HAS STOPPED" after exit transition. My code is

    first activity

    package com.ruben.myapplication;
    
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ImageView;
    import com.kogitune.activity_transition.ActivityTransitionLauncher;
    
    public class MainActivity extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ImageView imageView = (ImageView) findViewById(R.id.imageview);
            imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(MainActivity.this, Main2Activity.class);
                    startActivity(intent);
                    ActivityTransitionLauncher.with(MainActivity.this).from(view).launch(intent);
                }
            });
    
        }
    }
    
    

    second activity

    package com.ruben.myapplication;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    
    import com.kogitune.activity_transition.ActivityTransition;
    import com.kogitune.activity_transition.ExitActivityTransition;
    
    
    public class Main2Activity extends AppCompatActivity {
        private ExitActivityTransition exitTransition;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main2);
            exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.imageview)).start(savedInstanceState);
        }
    
        @Override
        public void onBackPressed() {
            exitTransition.exit(this);
        }
    }
    

    Logcat error Shows

     E/AndroidRuntime: FATAL EXCEPTION: main
                                                                             Process: com.ruben.myapplication, PID: 12101
                                                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ruben.myapplication/com.ruben.myapplication.Main2Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String)' on a null object reference
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2348)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410)
                                                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:135)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5351)
                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
                                                                              Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String)' on a null object reference
                                                                                 at com.kogitune.activity_transition.core.TransitionData.<init>(TransitionData.java:36)
                                                                                 at com.kogitune.activity_transition.core.TransitionAnimation.startAnimation(TransitionAnimation.java:27)
                                                                                 at com.kogitune.activity_transition.ActivityTransition.start(ActivityTransition.java:51)
                                                                                 at com.ruben.myapplication.Main2Activity.onCreate(Main2Activity.java:17)
                                                                                 at android.app.Activity.performCreate(Activity.java:6012)
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) 
                                                                                 at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:135) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5351) 
                                                                                 at java.lang.reflect.Method.invoke(Native Method) 
                                                                                 at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) 
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) 
    

    Can u pls help me as soon as possible ??

    opened by rubinnellikunnathu 5
  • Show Animations

    Show Animations

    Hi. thanks you for Previous help. i have one question. i want start animation such as this picture :

    set imageview Top of activity, and after the set this image. sort under this image another objects. How can I do this? please send me correct code. tnx <3

    opened by tellfa 5
  • At the beginning, the image be scaled.

    At the beginning, the image be scaled.

    Thank you for the useful library. I have 2 images with different ratio. In the start activity: 2016-03-07 18 34 51 In the destination activity, at the end, it like that: 2016-03-07 18 36 05 But at the beginning, it be scaled: 2016-03-07 18 38 30 On API >=21 it's fine. How to make the image don't be scaled. Thank you very much.

    opened by NtcWai 4
  • getArguments().getParcelable doesn't work with FragmentTransitionLauncher

    getArguments().getParcelable doesn't work with FragmentTransitionLauncher

    I am using FragmentTransitionLauncher with shared resource(image) from one fragment to another:

      final MoreAppInfoFragment toFragment = MoreAppInfoFragment.newInstance();
      FragmentTransitionLauncher.with(getActivity()).image(myBtimap).
      from(iconHolder).prepare(toFragment);
    

    I noticed that FragmentTransitionLauncher.prepare() method creates new Bundle obj sets him to fragment:

       public void prepare(android.support.v4.app.Fragment toFragment) {
       Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(this.context,
       this.fromView, this.bitmap);
       toFragment.setArguments(transitionBundle);}
    

    So instead of creating new Bundle, i get existing and put my Parcelable like this:

        toFragment.getArguments().putParcelable(MoreAppInfoFragment.APP_INFO_OBJ,    
        Parcels.wrap(new AppInfo()));
    

    And then start my fragment:

         getFragmentManager().beginTransaction().replace(R.id.fragmentContainer, 
         toFragment).addToBackStack(null).commit();
    

    And finally in my MoreAppInfoFragment onViewCreated i getArguments and it returns null:

        public void onViewCreated(View view, Bundle savedInstanceState) {
        AppInfo currentApp = 
        Parcels.unwrap(getArguments().getParcelable(APP_INFO_OBJ));//getArguments() = null}
    
    opened by TheLester 3
  • Image be cut by ViewGroup

    Image be cut by ViewGroup

    Firstly thanks to this, it is good and I have run several tests and they all works good.

    But when a view is in a ViewGroup and if the ViewGroup not full screen , then when the transition move to a position that the ViewGroup not covered, the view will disapper, can we fix this problem?

    opened by icyfox-bupt 3
  • Why not join multiple elements to share?

    Why not join multiple elements to share?

    Android 5.0 or above can be like this:

    Intent i = new Intent(mContext, Main2Activity.class); Pair<View, String> pair = new Pair<View, String>(holder.image,"image"); Pair<View,String> pairText = new Pair<View, String>(holder.text,"text"); ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(mContext, pair,pairText); startActivity(i,optionsCompat.toBundle());

    Does "PreLollipopTransition" also provide a similar API for doing this?

    opened by ghost 0
  • Not working properly in Recycleview

    Not working properly in Recycleview

    I am using this transition animation with the recycle view item but image scaling change in animation so it is not working properly. Give some solution. Thank You

    opened by vishalvanpariya 0
  • how to use in recycler view adapter

    how to use in recycler view adapter

    Hi, I have a RecyclerView that has children with two buttons and an image in background I want to show the background image in a separate activity when the show button is clicked. The problem is that i when i use this library in my adapter the animation doesn't start on the view. Instead it begins from left top corner of screen.

    Is there a way to fix it?

    opened by mr-sarsarabi 0
  • wrong scale in open and close fragment

    wrong scale in open and close fragment

    when i want show an image in start of opening fragment will be have following result and image is smaller than normal size!

    untitled

    also this problem is in close fragment.

    how can define scale type ?

    opened by saeedmozaffari 0
  • Image cannot scale out in cardview

    Image cannot scale out in cardview

    I try this method on recycleadapter click item

                FragmentTransitionLauncher
                        .with(mContext.getApplicationContext())
                        .image(bmp)
                        .from(mContext.findViewById(R.id.imgMusicPosterPreview))
                        .prepare(fragInfo);
    

    the image is not scalling out in cardview

    opened by segunmicheal27 1
Releases(1.3.3)
Owner
Takahiro Menju
Google Developers Expert for Android CyberAgent.Inc, AbemaTv.Inc @abema
Takahiro Menju
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Orbitary ?? Jetpack Compose animation library that allows you to implement animations such as shared element transition. Download Gradle Add the depen

Jaewoong Eum 503 Dec 30, 2022
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

?? Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Jaewoong Eum 504 Jan 2, 2023
This is a simple util to create Activity transition animation

TransitionHelper This is a simple util to create Activity transition animation API compatible with Android 2.2+ 中文说明 Screenshots How to use 1.startAct

ImmortalZ 1.6k Dec 12, 2022
Lightweight Android library for cool activity transition animations

Bungee min SDK 16 (Android Jellybean 4.1) written in Java A lightweight, easy-to-use Android library that provides awesome activity transition animati

Dean Spencer 172 Nov 18, 2022
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

Jake Klinker 1.3k Nov 25, 2022
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures

Stfalcon ImageViewer A simple and customizable full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" g

Stfalcon LLC 1.9k Jan 5, 2023
ViewAnimator view with a lollipop style reveal effect

ViewRevealAnimator Widget ViewAnimator view with a lollipop style reveal effect. Regular animation can be set (just like the default ViewAnimator) for

Alessandro Crugnola 339 Jun 3, 2022
Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+

CircularReveal Lollipop ViewAnimationUtils.createCircularReveal for everyone 14+ Yotube Video Checout demo application How to use: Use regular RevealF

Ozodrukh 2.5k Dec 29, 2022
App Shortcuts for Android on Pre Nougat 7.1!

Shortcuts for Android on Pre Nougat 7.1! WHAT IS ANDROID SHORTCUTS? The Android App Shortcuts Library have features of Android 7.1 Nougat, you can imp

Michele Lacorte 228 Nov 25, 2022
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Allows the easy creation of animated transition effects when the state of Android UI has changed

android-transition Android-Transition allows the easy creation of view transitions that reacts to user inputs. The library is designed to be general e

Kai 615 Nov 14, 2022
ArcAnimator helps to create arc transition animation: 2.3.+

ArcAnimator ArcAnimator helps to create arc transition animation: 14+ | ArcAnimator Demo | TransitionLoop Demo* *TransitionLoop Prototype by Min-Sang

Asyl Isakov 1.2k Dec 20, 2022
Android Transition animations explanation with examples.

UNMAINTAINED No maintainance is intended. The content is still valid as a reference but it won't contain the latest new stuff Android Transition Frame

Luis G. Valle 13.6k Dec 28, 2022
🌠 Transform into a different view or activity using morphing animations.

TransformationLayout ?? Transform into a different view or activity using morphing animations. Using Transformation motions of new material version. D

Jaewoong Eum 2k Jan 3, 2023
Easily add slide to dismiss functionality to an Activity

Slidr Easily add slide-to-dismiss functionality to your Activity by calling Slidr.attach(this) in your onCreate(..) method. Usage An example usage: pu

Drew Heavner 2.7k Jan 6, 2023
Wave effect of activity animation

WaveCompat Wave effect of activity animation How to use 1. Bind wave touch helper to a view which will start an activity when it clicked: WaveTouchHel

WangJie 348 Nov 29, 2022
Group of libraries to help you build better animations with Jetpack Compose

Group of libraries to help you build better animations with Jetpack Compose

null 36 May 12, 2022
:sparkles: An easy way to implement an elastic touch effect for Android.

ElasticViews ✨ An easy way to implement an elastic touch effect for Android. Including in your project Gradle Add below codes to your root build.gradl

Jaewoong Eum 763 Dec 29, 2022