java - Rotate Animation of an ImageView -


i have camera application. whenever device orientation changed portrait landscape , vice versa, animate imageview side.

here's code, animation done on first set, if event of orientation change occures again, nothing happens.

here's code:

  @override      public void onsensorchanged(sensorevent event) {          if (event.values[1]<6.5 && event.values[1]>-6.5) {              if (orientation!=1) { // portrait                  animation = new rotateanimation(0,90,rotateanimation.relative_to_self, 0.5f, rotateanimation.relative_to_self, 0.5f);                  animation.setfillafter(true);                   animation.setfillenabled(true);                  animation.setduration(0);                    imageview.setanimation(animation);              }              orientation=1;          } else {              if (orientation!=0) { // landscape                  animation = new rotateanimation(0,270,rotateanimation.relative_to_self, 0.5f, rotateanimation.relative_to_self, 0.5f);                  animation.setfillafter(true);                   animation.setfillenabled(true);                  animation.setduration(0);                    imageview.setanimation(animation);              }              orientation=0;          }      } 

why happen, how can make sure whenever event occures animation applied imageview other rotate paramters, , not using same angle?

when animate view using normal view animations, you're animating position @ drawn. you're not affecting actual location in layout. assuming intend make view change position permanently, you'll need update layout parameters of view after animation complete match movement make animation.

or after animation, setcontentview proper layout xml again..


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -