0

I'm trying to get a custom indeterminate ProgressBar by using a rotating drawable in Android 4.1. I'm doing this as following:

 <?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="360"
android:toDegrees="0"
android:drawable="@drawable/image_for_rotation"
android:pivotX="50%"
android:pivotY="50%" />

it seems like fromDegrees and toDegrees parameters just don't work, the image only rotates clockwise, but I need in to rotate ccw. When I change animated-rotate to rotate, they start working, however this is not what I need. Any suggestion to get it working?

enter image description here

Droidman
  • 11,485
  • 17
  • 93
  • 141

2 Answers2

4

I think the point is if you use <animated-rotate> it is a non public API.

I can't find any official documentation about it.

and it is actually ignoring whatever values you put in fromDegrees and toDegrees. You can remove both attributes and it will still spin.

You said you don't want to use rotate, but that is the only other simple XML answer I can find:

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
  android:drawable="@android:drawable/ic_lock_power_off"
  android:pivotX="50%"
  android:pivotY="50%"
  android:fromDegrees="0"
  android:toDegrees="-360" />

What is the reason for wanting <animated-rotate> and not <rotate> ?

If you want to set a slower or faster frame count, you should check this answer here:

https://stackoverflow.com/a/14996762/413127

Community
  • 1
  • 1
Blundell
  • 75,855
  • 30
  • 208
  • 233
  • if it is not a public API, why does it work then? I use no external libs. Well its difficult to tell without seeing.. take a look at my ProgressBar. 'rotate' literally ROTATES it, nothing more. 'animated-rotate' runs smooth like a real frame-by-frame animation. That's why I'm looking for a way to customize it – Droidman Jul 27 '13 at 00:44
  • As I said, read the stackoverflow post I linked you can control the frame rate. – Blundell Jul 27 '13 at 08:51
0

change

android:fromDegrees="360"
android:toDegrees="0"

to

android:fromDegrees="0"
android:toDegrees="360"
Damir Mailybayev
  • 1,031
  • 1
  • 9
  • 14