GithubHelp home page GithubHelp logo

aaaliua / activityoptionsics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaleai/activityoptionsics

0.0 2.0 0.0 5.82 MB

The lib can make the ActivityOptions animations use in Android api3.1+

Home Page: http://www.cnblogs.com/tianzhijiexian/p/4128045.html

License: Eclipse Public License 1.0

Java 100.00%

activityoptionsics's Introduction

ActivityOptionsICS

f you are thinking on customizing the animation of Activity transition then probably you would look for ActivityOptions.However ActivityOptions class introduced in Android 4.1 (Jelly bean). ActivityOptionsICS can make it use in 3.1+. The library provided some methods which can help you to customize the Activity Animation.

Screenshot

Please waiting for loading...

ActivityOptionsCompatICS

  1. public static ActivityOptionsCompatICS makeCustomAnimation(Context context,int enterResId, int exitResId)

This method allows to pass custom animation and when the Atyctivi is launched, it gets rendered accordingly. Here you can pass animation for transitioning out Activity as well as for transitioning in Activity

  1. public static ActivityOptionsCompatICS makeScaleUpAnimation(View source, int startX, int startY, int width, int height)

This method scales up the Activity from the initial size to its final representational size. It can be used to scale up the activity from the view which has launched this activity.

  1. public static ActivityOptionsCompatICSmakeThumbnailScaleUpAnimation(View source, Bitmap thumbnail, int startX, int startY)

In this animation, a thumbnail of the activity scales up to the final size of the activity.

  1. public static ActivityOptionsCompatICS makeSceneTransitionAnimation(Activity activity, View view, sharedElement,int sharedElementId)

This method carries the position of one shared element to the started Activity.The position of sharedElement will be used as the epicenter for the exit Transition.

  1. public static ActivityOptionsCompatICS makeSceneTransitionAnimation(Activity activity, Pair<View, Integer>... sharedElements)

This method carries the position of multiple shared elements to the started Activity. The position of the first element in sharedElements will be used as the epicenter for the exit Transition. The position of the associated shared element in the launched Activity will be the epicenter of its entering Transition.

ActivityCompatICS

  1. public static void startActivity(Activity activity, Intent intent, Bundle bundle)

TransitionCompat

  1. TransitionCompat.startTransition(this, R.layout.activity_target);
  2. TransitionCompat.finishAfterTransition(this);

How to use

If you want use this library, you only have to download this project, import it into your workspace and add the project as a library in your android project settings.

In MainActivity

makeCustomAnimation

   public void customAnim() {
    		ActivityOptionsCompatICS options = ActivityOptionsCompatICS.makeCustomAnimation(this,
    				R.anim.slide_bottom_in, R.anim.slide_bottom_out);
    		ActivityCompatICS.startActivity(MainActivity.this, intent, options.toBundle());
    	}

makeScaleUpAnimation

public void scaleUpAnim(View view) {
		ActivityOptionsCompatICS options = ActivityOptionsCompatICS.makeScaleUpAnimation(view,
				 0, 0, //拉伸开始的坐标
	             view.getMeasuredWidth(), view.getMeasuredHeight());//初始的宽高
		ActivityCompatICS.startActivity(MainActivity.this, intent, options.toBundle());
	}

makeThumbnailScaleUpAnimation

public void thumbNailScaleAnim(ImageView view) {
		view.setDrawingCacheEnabled(true);
		 Bitmap bitmap = view.getDrawingCache();
		  ActivityOptionsCompatICS options = ActivityOptionsCompatICS.makeThumbnailScaleUpAnimation(
		    view, bitmap, 0, 0);
		  // Request the activity be started, using the custom animation options.
		  ActivityCompatICS.startActivity(MainActivity.this, intent, options.toBundle());
		  //view.setDrawingCacheEnabled(false);
	}

makeSceneTransitionAnimation

screenTransitAnimByPair(
				Pair.create((View)orginalImageView, R.id.target_imageView),
				Pair.create((View)orginalTextView, R.id.target_textView),
				Pair.create((View)chromeIView, R.id.target_chrome_imageView));   

public void screenTransitAnimByPair(Pair<View, Integer>... views) {
		isSceneAnim = true;
		ActivityOptionsCompatICS options = ActivityOptionsCompatICS.makeSceneTransitionAnimation(
				MainActivity.this, views);
		ActivityCompatICS.startActivity(MainActivity.this, intent, options.toBundle());
	}

##In TargetActivity 1.make translucentTheme in style.xml

<style name="TranslucentTheme" parent="AppBaseTheme">
    <item name="android:windowIsTranslucent">true</item>
</style

2.set targetActivity's theme in manifest.xml

<activity   
	android:name="com.example.activityoptionsjbtest.TargetActivity"   
	android:theme="@style/TranslucentTheme" />     

3.start transition in targetActivity

public class TargetActivity extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_target);

	    TransitionCompat.startTransition(this, R.layout.activity_target);
    }
    
    @Override
    public void onBackPressed() {
	    //super.onBackPressed();
	    TransitionCompat.finishAfterTransition(this); 
    }
}  

Developed By

Kale [email protected]

activityoptionsics's People

Contributors

kaleai avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.