RotateDrawable Programáticamente en android

¿Cómo puedo dar fromFegrees , toDegrees and android:color="#000000" programa?

 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="@android:color/transparent" android:width="10dp"/> <solid android:color="#000000" /> </shape> </rotate> </item> </layer-list> 

Estoy utilizando este xml en el fondo de la vista.

Tengo que crear el triángulo programáticamente. Por lo que es necesario crear RotationDrawable mediante programación.

Aquí está una buena solución para poner un dibujado giratorio para una imageView:

 RotateAnimation anim = new RotateAnimation(0.0f, 360.0f , Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); anim.setInterpolator(new LinearInterpolator()); anim.setRepeatCount(Animation.INFINITE); anim.setDuration(3000); iv.setAnimation(anim); iv.startAnimation(anim); 

Puede utilizar una Matriz para rotar imágenes mediante programación:

 rotationMatrix = new Matrix(); // Set the scale type of your ImageView to "Matrix" yourImageView.setScaleType(ScaleType.MATRIX); // to set the rotation to a specific degree: rotationMatrix.setRotate(degrees); // or add some degrees to the current rotation rotationMatrix.postRotate(degrees); // apply matrix to your ImageView yourImageView.setImageMatrix(rotationMatrix); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.