Android ImageView rotation <API level 11

So, in API Level 11, Google introduced the ability to rotate ImageView (Yay, after they introduced the ability to animate such a rotation, yay smart thinking, yay!)

But how do I go to rotate an ImageView using, for example, API Level 8? I cannot use setRotation () as described above.

+6
source share
2 answers

I started by creating BitMap and rotating the canvas / matrix, however this was not a good solution. Finally, just replacing the available ones has ended if the conditions are met. I have to say that this is an ExpandableListView where the cells are reused when drawing.

 if (isExpanded) { ImageView view = (ImageView) convertView.findViewById(R.id.ImageView); view.setImageResource(R.drawable.quickactions_button_normal_down); } if (!isExpanded) { ImageView view = (ImageView) convertView.findViewById(R.id.ImageView); view.setImageResource(R.drawable.quickactions_button_normal); } 

I'm usually not an Android developer, but I'm really surprised that you can animate the rotation, but not statically set the rotation of the picture. Logically, the first is a subset of the second, and not vice versa.

+2
source

RotationAnimation was present from Api level 1

 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(1); animation.setFillAfter(true); imageView.startAnimation(animation ); 
+7
source

Source: https://habr.com/ru/post/898512/


All Articles