java - Android Object Animation xml -
i trying create translate image (ball) using xml objectanimator. when try reference objectanimator xml file, says getapplicationcontext() might return null. when flash phone, crashed immediately. when take out line , setanimationlistener line, works. however, if there 1 of lines, not work.
mainactivity.java
public class mainactivity extends actionbaractivity implements animation.animationlistener{ imageview ball; button moveb1; animation move; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); ball = (imageview) findviewbyid(r.id.ball); moveb1 = (button) findviewbyid(r.id.move1); move = animationutils.loadanimation(getapplicationcontext(), r.animator.move); move.setanimationlistener(this); } }
move.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together"> <objectanimator android:propertyname="x" android:duration="500" android:valueto="400" android:valuetype="inttype"/> <objectanimator android:propertyname="y" android:duration="500" android:valueto="300" android:valuetype="inttype"/> </set>
any appreciated.
animationutils:createanimationfromxml
line 112 - 125 android have not support "objectanimator"
maybe need animatorinflater.loadanimator
Comments
Post a Comment