layout - How can I rotate image view during pathAnimation in android? -
i first setting path through coordinates using path.lineto()
function.
now animating image view on final path using value animator. above api 21
pathanimator = objectanimator.offloat(monsterimage, "x", "y", path);
for api 11+ used this:
pathanimator = valueanimator.offloat(0.0f, 1.0f); pathanimator.addupdatelistener(new valueanimator.animatorupdatelistener() { float[] point = new float[2]; @override public void onanimationupdate(valueanimator animation) { float val = animation.getanimatedfraction(); pathmeasure pathmeasure = new pathmeasure(path, false); pathmeasure.getpostan((pathmeasure.getlength() - 1) * val, point, null); monsterimage.setx(point[0]); monsterimage.sety(point[1]); } });
but want whenever animation changes direction should rotate image. i.e. each line rotate image 90 degree clockwise.
how can this?
Comments
Post a Comment