use of com.example.jingbin.cloudreader.view.CustomChangeBounds in project CloudReader by youlookwhat.
the class BaseHeaderActivity method setMotion.
/**
* 设置自定义 Shared Element切换动画
* 默认不开启曲线路径切换动画,
* 开启需要重写setHeaderPicView(),和调用此方法并将isShow值设为true
*
* @param imageView 共享的图片
* @param isShow 是否显示曲线动画
*/
protected void setMotion(ImageView imageView, boolean isShow) {
if (!isShow) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//定义ArcMotion
ArcMotion arcMotion = new ArcMotion();
arcMotion.setMinimumHorizontalAngle(50f);
arcMotion.setMinimumVerticalAngle(50f);
//插值器,控制速度
Interpolator interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);
//实例化自定义的ChangeBounds
CustomChangeBounds changeBounds = new CustomChangeBounds();
changeBounds.setPathMotion(arcMotion);
changeBounds.setInterpolator(interpolator);
changeBounds.addTarget(imageView);
//将切换动画应用到当前的Activity的进入和返回
getWindow().setSharedElementEnterTransition(changeBounds);
getWindow().setSharedElementReturnTransition(changeBounds);
}
}
Aggregations