ObjectAnimator.ofFloat(Object target, String xPropertyName, String yPropertyName, Path path)
似乎在API 21中工作,但不是23?简单再现:这是活动和布局。试着长按文本视图,这两个级别都可以工作。不过,只需轻点上的观点:21级的作品,但不是23路径上的ObjectAnimator无法在棉花糖上工作?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final View hello = findViewById(R.id.hello);
final Path p = new Path();
p.addCircle(-200, 0, 100, Path.Direction.CW);
hello.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ObjectAnimator a = ObjectAnimator.ofFloat(hello, "translationX", "translationY", p);
a.setDuration(1000);
a.start();
}
});
hello.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ObjectAnimator a = ObjectAnimator.ofFloat(hello, "scaleX", 2);
a.setDuration(1000);
a.start();
return true;
}
});
}
}
-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="letstwinkle.com.pathtest.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="63dp"
android:layout_marginTop="210dp"
android:id="@+id/hello"
android:background="#880033"/>
</RelativeLayout>
这可能是与此相同的错误在六月报道。 https://code.google.com/p/android/issues/detail?id=212776
我AppCompatActivity和仿真器版本22和23测试:适用于22,开始于23移动,但经过正确的冻结。 – 0X0nosugar
我已经添加了一个更新监听器,并查看了动画值 - 它在API 21上有所区别,但在API 23上它是稳定的,总是与“-100”相同 - 确切而言。 –
并与path.lineTo(200,200) - 它是完美的工作。需要深入到圈子里,甚至是使用textview的东西已经改变了。 –