alynx-live-wallpaper
alynx-live-wallpaper copied to clipboard
不知道有没有办法让他从应用到桌面的时候从2倍大小顺滑的以贝塞尔曲线的时间轴过度到1倍大小
首先我是个后端,不懂安卓在学安卓,clone了您的项目。
想实现的效果是:应用到桌面的时候从2倍大小顺滑的以贝塞尔曲线的时间轴过度到1倍大小
目前我尝试过在onVisibilityChanged事件时用 ValueAnimator这个类时间动画的效果,但问题是不够丝滑。请问有没有一种方案让他更丝滑一点呢?还是我用错类了
目前星空动态壁纸
里体现的效果是很丝滑的,但我不知道他是怎么实现的。
希望大佬给条明路哇!
下面是我的主要代码
// GLES30WallpaperRenderer类下加了个这个方法
void setScale(float scale){
mvp[0] = mvp[5] = mvp[10] = mvp[15] = 1.0f;
final float videoRatio = (float)videoWidth / videoHeight;
final float screenRatio = (float)screenWidth / screenHeight;
if (videoRatio >= screenRatio) {
Matrix.scaleM(
mvp, 0,
((float)videoWidth / videoHeight) / ((float)screenWidth / screenHeight)+scale,
1+scale, 1
);
}else{
Matrix.scaleM(
mvp, 0, 1+scale,
((float)videoHeight / videoWidth) / ((float)screenHeight / screenWidth)+scale,
1
);
}
}
// onVisibilityChanged 方法内部
if (animator == null){
// 初始化
animator = ValueAnimator.ofFloat((float) 1,(float) 0);
animator.setDuration(1000);
animator.setInterpolator(new CubicBezierInterpolator((float) .42,0,(float).58,1));
// animator.setInterpolator(new LinearInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // 监听值的变化
@Override
public void onAnimationUpdate(ValueAnimator animator) {
float value = (float) animator.getAnimatedValue();// 运行当前时间点的一个值
if (value>1){
return;
}
if (value<0.01){
value=0;
}
renderer.setScale(value);
if (value == 0){
animator.cancel();
Toast.makeText(context, "动画停止~", Toast.LENGTH_SHORT).show();
}
}
});
if (!animator.isRunning()){
animator.start();
}else{
Toast.makeText(context, "没有播放玩啊", Toast.LENGTH_SHORT).show();
}
}
@AlynxZhou
就是你这个不够丝滑大概是什么样子的,能给我录个屏看看吗?
录个屏