Android Animate Rotate

I did some digging in Android code and saw use in an undefined execution step. after trying to create my own drawable with this tag:

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/spinner_pia" android:pivotX="50%" android:pivotY="50%" android:framesCount="12" android:frameDuration="100" /> 

I get an error: "The resource identifier was not found for the" frameDuration "attribute in the" android "package - this means that frameDuration is a private attribute. Is there a way to use this animation-rotation function?

My task is to replace the default undefined progress bar. I would like to do this with a minimal amount of code (just change a few attributes if possible). Using the ProgressBar view, set:

 android:indeterminateOnly="true" android:indeterminateBehavior="cycle" android:indeterminateDuration="3500" android:indeterminateDrawable="@drawable/pia_sivuvator" 

and the point "@ drawable / pia_sivuvator" to this object would make my task as graceful as they are, but I am stuck in these private attributes.

help?

+48
android animation progress-bar customization
Dec 05 2018-10-15
source share
5 answers

I ran into the same problem. You can exclude these options (framesCount and frameDuration), and this may work for you. I tried to just exclude them, and it was animated, but the width / height that I set was not respected, so I just created a rotation animation and ImageView to apply it. Here's the animation file (res / anim / clockwise_rotation.xml):

 <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:interpolator="@android:anim/linear_interpolator" android:toDegrees="360" android:pivotX="50%" android:pivotY="50%" android:duration="1000" android:startOffset="0" /> 

Then you simply inflate the animation, set the number of repetitions and start it from the view

 Animation rotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_rotation); rotation.setRepeatCount(Animation.INFINITE); myView.startAnimation(rotation); 
+57
Jan 30 '11 at 23:20
source share
— -

Instead of creating animations (more code is required, not just for XML configuration), use layer-list as a paintable resource. Interestingly, layer-list is more fluid than animated-rotate .

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

Then, of course, use it in styles, as Mario Lenzi wrote:

 <style name="YourProgressBarStyle" parent="@android:style/Widget.ProgressBar"> <item name="android:indeterminateDrawable">@drawable/progress_bar_indeterminate</item> </style> 
+7
Sep 30 '14 at 13:07
source share

I don't know how to get around private attributes, I have the same problem.

By the way, if you want to change those attributes of the ProgressBar:

 android:indeterminateOnly="true" android:indeterminateBehavior="cycle" android:indeterminateDuration="3500" android:indeterminateDrawable="@drawable/pia_sivuvator" 

you can do this easily using the Styles framework, which defines the ProgressBar style in the values/styles.xml that extends the standard android:

 <style name="YourProgressBarStyle" parent="@android:style/Widget.ProgressBar"> <item name="android:indeterminateDrawable">@drawable/progress_bar_indeterminate</item> </style> 

and then apply it to the execution line in the xml layout file.

 ... <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/YourProgressBarStyle"/> ... 
+6
Dec 29 '11 at 2:37
source share

I solved this using this drawable xml. Although it looks so smooth in newer versions of Android:

 <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/spinner_pia" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="1080" /> 
+5
Jul 14 '12 at 18:40
source share

Here is a simple explanation of the rotation animation. Try it, it will help you

http://androidtutorials60.blogspot.in/2013/09/simple-rotate-animation-in-android.html

 <rotate xmlns:android=""http://schemas.android.com/apk/res/android""> android:duration="4000" android:fromdegrees="0" android:pivotx="50%" android:pivoty="50%" android:todegrees="360" android:toyscale="0.0" </rotate> 
+4
Sep 26 '13 at 7:40
source share



All Articles