android - How to animate an icon for expand/collapse view? -


i have icon:

enter image description here

and when press item in listview want rotate 180°. when click again want rotate 180° get's it's original position.

first tried:

view.animate().rotation(180).setduration(500).start(); 

but fires once. after tried:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:fillafter="true"     android:fillenabled="true">      <rotate         android:duration="500"         android:fromdegrees="0"         android:pivotx="50%"         android:pivoty="50%"         android:todegrees="180" /> </set> 

but animation starts arrow showing buttom , rotating top if arrow shows top.

so how can make working?

user following code click event of image:

objectanimator anim = objectanimator.offloat(v, "rotation",rotationangle, rotationangle + 180);             anim.setduration(500);             anim.start();             rotationangle += 180;             rotationangle = rotationangle%360; 

and make rotationangle global variable:

int rotationangle = 0; 

Comments

Popular posts from this blog

c - Calling a function within a loop -

vb.net - Unbound DataGridView add row with checkbox error -

How i fill combobox items in Radgridview manually using in vb.net -