android.transition.Transition.setDuration()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(204)

本文整理了Java中android.transition.Transition.setDuration()方法的一些代码示例,展示了Transition.setDuration()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transition.setDuration()方法的具体详情如下:
包路径:android.transition.Transition
类名称:Transition
方法名:setDuration

Transition.setDuration介绍

暂无

代码示例

代码示例来源:origin: blundell/QuickSand

public void setDuration(long duration) {
  transition.setDuration(duration);
}

代码示例来源:origin: DroidsOnRoids/Workcation

public TransitionBuilder duration(long duration) {
  transition.setDuration(duration);
  return this;
}

代码示例来源:origin: blundell/QuickSand

private Transition getTransition() {
  Transition transition = new Explode();
  transition.setDuration(TimeUnit.SECONDS.toMillis(6));
  return transition;
}

代码示例来源:origin: blundell/QuickSand

private Transition getTransition() {
  Transition transition = new Explode();
  transition.setDuration(TimeUnit.SECONDS.toMillis(6));
  return transition;
}

代码示例来源:origin: stackoverflow.com

public class secondActivity extends Activity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ///
   getWindow().requestFeature(android.view.Window.FEATURE_CONTENT_TRANSITIONS);
   Transition ts = new Slide();  //Slide(); //Explode();
   ts.setDuration(3000);
   getWindow().setEnterTransition(ts);
   getWindow().setExitTransition(ts);
   ///
   setContentView(R.layout.activity_scene_transition);
   if (savedInstanceState == null) {
     getFragmentManager().beginTransaction()
         .add(R.id.container, new PlaceholderFragment())
         .commit();
   }
 }

代码示例来源:origin: Wing-Li/Material-Animations-CN

private void setupWindowAnimations() {
  // 我们不想定义新的 Enter Transition。
  // 只更改默认的过渡持续时间
  getWindow().getEnterTransition().setDuration(getResources().getInteger(R.integer.anim_duration_long));
}

代码示例来源:origin: stackoverflow.com

ts.setDuration(5000);

代码示例来源:origin: vipulyaara/betterHotels

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setupEnterAnimation() {
  Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.change_bounds_with_arc);
  transition.setDuration(300);
  getWindow().setSharedElementEnterTransition(transition);
  transition.addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
    }
    @Override
    public void onTransitionEnd(Transition transition) {
    }
    @Override
    public void onTransitionCancel(Transition transition) {
    }
    @Override
    public void onTransitionPause(Transition transition) {
    }
    @Override
    public void onTransitionResume(Transition transition) {
    }
  });
}

代码示例来源:origin: vipulyaara/betterHotels

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setupEnterAnimation() {
  Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.change_bounds_with_arc);
  transition.setDuration(300);
  getWindow().setSharedElementEnterTransition(transition);
  transition.addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
    }
    @Override
    public void onTransitionEnd(Transition transition) {
    }
    @Override
    public void onTransitionCancel(Transition transition) {
    }
    @Override
    public void onTransitionPause(Transition transition) {
    }
    @Override
    public void onTransitionResume(Transition transition) {
    }
  });
}

代码示例来源:origin: vipulyaara/betterHotels

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setupEnterAnimation() {
  Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.change_bounds_with_arc);
  transition.setDuration(300);
  getWindow().setSharedElementEnterTransition(transition);
  transition.addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
    }
    @Override
    public void onTransitionEnd(Transition transition) {
    }
    @Override
    public void onTransitionCancel(Transition transition) {
    }
    @Override
    public void onTransitionPause(Transition transition) {
    }
    @Override
    public void onTransitionResume(Transition transition) {
    }
  });
}

代码示例来源:origin: jonasbleyl/recurrence

@Override
  public void onClick(View view) {
    Intent intent = new Intent(context, ViewActivity.class);
    intent.putExtra("NOTIFICATION_ID", reminderList.get(viewHolder.getAdapterPosition()).getId());
    // Add shared element transition animation if on Lollipop or later
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      CardView cardView = (CardView) view.findViewById(R.id.notification_card);
      TransitionSet setExit = new TransitionSet();
      Transition transition = new Fade();
      transition.excludeTarget(android.R.id.statusBarBackground, true);
      transition.excludeTarget(android.R.id.navigationBarBackground, true);
      transition.excludeTarget(R.id.fab_button, true);
      transition.excludeTarget(R.id.recycler_view, true);
      transition.setDuration(400);
      setExit.addTransition(transition);
      ((Activity) context).getWindow().setSharedElementsUseOverlay(false);
      ((Activity) context).getWindow().setReenterTransition(null);
      ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(((Activity) context), cardView, "cardTransition");
      ActivityCompat.startActivity(((Activity) context), intent, options.toBundle());
      ((RecyclerListener) context).hideFab();
    } else {
      context.startActivity(intent);
    }
  }
});

代码示例来源:origin: jonasbleyl/recurrence

public void setupTransitions() {
  // Add shared element transition animation if on Lollipop or later
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    // Enter transitions
    TransitionSet setEnter = new TransitionSet();
    Transition slideDown = new Explode();
    slideDown.addTarget(headerView);
    slideDown.excludeTarget(scrollView, true);
    slideDown.setDuration(500);
    setEnter.addTransition(slideDown);
    Transition fadeOut = new Slide(Gravity.BOTTOM);
    fadeOut.addTarget(scrollView);
    fadeOut.setDuration(500);
    setEnter.addTransition(fadeOut);
    // Exit transitions
    TransitionSet setExit = new TransitionSet();
    Transition slideDown2 = new Explode();
    slideDown2.addTarget(headerView);
    slideDown2.setDuration(570);
    setExit.addTransition(slideDown2);
    Transition fadeOut2 = new Slide(Gravity.BOTTOM);
    fadeOut2.addTarget(scrollView);
    fadeOut2.setDuration(280);
    setExit.addTransition(fadeOut2);
    getWindow().setEnterTransition(setEnter);
    getWindow().setReturnTransition(setExit);
  }
}

代码示例来源:origin: aartikov/Alligator

@SuppressLint("RtlHardcoded")
  private TransitionAnimation createSlideAnimation(boolean forward, AnimationData animationData) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Transition enterTransition = forward ? new Slide(Gravity.RIGHT) : new Slide(Gravity.LEFT);
      Transition exitTransition = forward ? new Slide(Gravity.LEFT) : new Slide(Gravity.RIGHT);
      LollipopTransitionAnimation animation = new LollipopTransitionAnimation(enterTransition, exitTransition);
      animation.setAllowEnterTransitionOverlap(false);

      Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container);
      if (currentFragment instanceof SharedElementProvider) {
        SharedElementProvider sharedElementProvider = (SharedElementProvider) currentFragment;
        View sharedElement = sharedElementProvider.getSharedElement(animationData);
        String shareElementName = sharedElementProvider.getSharedElementName(animationData);
        animation.addSharedElement(sharedElement, shareElementName);
        Transition moveTransition = TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move);
        moveTransition.setDuration(600);
        animation.setSharedElementTransition(moveTransition);
      }
      return animation;
    } else {
      int enterAnimRes = forward ? R.anim.slide_in_right : R.anim.slide_in_left;
      int exitAnimRes = forward ? R.anim.slide_out_left : R.anim.slide_out_right;
      return new SimpleTransitionAnimation(enterAnimRes, exitAnimRes);
    }
  }
}

相关文章