【发布时间】:2013-09-09 10:49:27
【问题描述】:
我有以下动画:
ImageView fallingLeave = (ImageView) rootView.findViewById(R.id.lemonpiece1_large);
mButtonProxy = AnimatorProxy.wrap(fallingLeave);
// Set up the path we're animating along
AnimatorPath path = new AnimatorPath();
path.moveTo(0,0);
path.curveTo(0, 0, 0 , 80, -80, 70);
fallingLeave.setRotation(80);
path.curveTo(-80, 70, -80, 120, 80, 140);
path.curveTo(80, 140, 80, 190, -80, 210);
// Set up the animation
final ObjectAnimator anim = ObjectAnimator.ofObject(this, "buttonLoc",
new PathEvaluator(), path.getPoints().toArray());
anim.setDuration(2000);
anim.start();
问题是路径设置为固定像素。我想要做的是独立设置路径像素。有什么想法可以实现吗?
我尝试将变量链接到dimensions.xml,但它不起作用,我宁愿将像素路径与像素密度比相乘,但我不知道是否有可以返回密度比值的函数用于设备。
任何帮助表示赞赏。
【问题讨论】:
-
[Context.getResources.getDimensionsPixelSize()](http://developer.android.com/reference/android/content/res/Resources.html#getDimensionPixelSize(int))从未失败过。也许您可以详细说明为什么这对您不起作用。但这是要遵循的方法,因为它更易于配置。