2

如果我有视图的(x,y),如何实现棉花糖的默认启动器(或Google即时启动器/ Nova启动器)应用程序启动动画。动画从图标开始,并对已启动的应用程序进行全屏矩形显示。现在,我启动使用下面的代码的应用程序:棉花糖应用程序启动动画

Intent intent = getActivity().getPackageManager() 
         .getLaunchIntentForPackage("com.android.example"); 
getActivity().startActivity(intent); 

下面是它的样子:

Marshmallow app launch animation

+0

你知道了吗? – timothyjc

+0

看看我的答案在这里:http://stackoverflow.com/a/38422411/396106 – timothyjc

+0

@timothyjc谢谢!请在此发布您的答案,以便我可以将其设置为接受的答案:) – Sazid

回答

0

FROM:https://stackoverflow.com/a/38422411/1941132

我发现在发射源的答案代码here

Bundle optsBundle = null; 
      ActivityOptions opts = null; 
      if (Utilities.ATLEAST_MARSHMALLOW) { 
       int left = 0, top = 0; 
       int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); 
//     if (v instanceof TextView) { 
//      // Launch from center of icon, not entire view 
//      Drawable icon = Workspace.getTextViewIcon((TextView) v); 
//      if (icon != null) { 
//       Rect bounds = icon.getBounds(); 
//       left = (width - bounds.width())/2; 
//       top = v.getPaddingTop(); 
//       width = bounds.width(); 
//       height = bounds.height(); 
//      } 
//     } 
       opts = ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); 
      } else if (!Utilities.ATLEAST_LOLLIPOP) { 
       // Below L, we use a scale up animation 
       opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); 
      } else if (Utilities.ATLEAST_LOLLIPOP_MR1) { 
       // On L devices, we use the device default slide-up transition. 
       // On L MR1 devices, we use a custom version of the slide-up transition which 
       // doesn't have the delay present in the device default. 
       opts = ActivityOptions.makeCustomAnimation(context, R.anim.task_open_enter, R.anim.no_anim); 
      } 
      optsBundle = opts != null ? opts.toBundle() : null; 

      context.startActivity(intent, optsBundle);