像素密度我有一个下面的动画:的Android爪哇确定在代码
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,但它没有工作,我宁愿用像素密度比MULTIPLY像素路径,但我不知道是否有函数可以返回密度值设备的比率。
任何帮助表示赞赏。
'[Context.getResources.getDimensionsPixelSize()](http://developer.android.com/reference/android/content/res/Resources.html#getDimensionPixelSize(int))'从未失败过。也许你可以详细说明为什么这不适合你。但是这是遵循的方法,因为它可以更好地配置为以这种方式工作。 – gunar