android - Android椭圆轨道动画
问题描述
我将它用于椭圆路径中的轨道视图,但我的问题是当视图到达中间时速度有点慢!
public class morbit extends Animation {
@Override
public boolean willChangeBounds() {
return true;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degg = interpolatedTime * 360;
float angleDeg = (degg) % 360;
double sino = Math.sin(degg * Math.PI / -180);
sino= Math.abs(sino);
double coso = Math.cos(degg * Math.PI / -180);
coso= Math.abs(coso);
double rrr = 40 + (sino * 150);
float angleRad = (float) Math.toRadians(angleDeg);
angleRad = angleRad;
float y = (float) (40 * Math.cos(angleRad));
float x = (float) (rrr * Math.sin(angleRad));
t.getMatrix().setTranslate((float)x, (float)y);
}
}
. . .
morbit an = new morbit();
an.setDuration(6000);
an.setRepeatMode(Animation.INFINITE);
an.setRepeatCount(9999);
an.setInterpolator(new LinearInterpolator());
((ImageView) findViewById(R.id.dottx)).startAnimation(an);
我用过LinearInterpolator
,但对我没有帮助。
解决方案
我希望您不会仍然坚持这一点,但对于其他任何人,请尝试交换:
sino and coso for
double sino =Math.sin(Math.PI + 200);
double coso = Math.cos(Math.PI + 400);
并将 rrr 换成
double rrr = 40 + (sino * 250);
我现在自己正在处理这个问题,所以我不太确定 interpolatedTime 的用途,尽管我猜它可以确保动画均匀分布。没有它,我似乎没有任何问题,所以也许这就是问题所在。
推荐阅读
- python - Python - 如何将现有字典添加到一组新键中
- r - rgl:如何制作更高分辨率的快照?
- perl - Perl/DBI selectrow_array 范围混淆
- android - 为什么安装时应用名称不显示在顶部?
- python - PythonKit 错误“找不到 Python 库。使用 Python 库的路径设置 PYTHON_LIBRARY 环境变量”
- python-3.x - 使用中值基础特定列值选择的 Python 插补值
- google-cloud-platform - 有没有办法在谷歌秘密管理器中对服务帐户访问特定秘密进行改造
- android - 在下载管理器通知中显示下载速度
- reporting-services - SSRS 使用报表目录报表超链接到报表管理器上的其他报表
- html - 我们可以通过在 vba 中使用 url 来获取特定数据吗