Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jeremy Miller
2,455 PointsAnimation Rotate
I want to rotate an image just like the star mike had in his crystal ball app when is the best place to find easy to follow descriptions on the way do do this effectively. the development site from google not s well documented in an example.
2 Answers
Ben Jakuben
Treehouse TeacherHi Jeremy,
Here is Mike's code! It involves a custom animation XML file. Hope this is enough for you - let us know if you have any follow-up questions.
protected ImageView mGoldStar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoldStar = (ImageView) findViewById(R.id.goldStar);
Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotate);
rotation.setRepeatCount(Animation.INFINITE);
mGoldStar.startAnimation(rotation);
}
res > anim > rotate.xml
<?xml version="1.0" encoding="UTF-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="2"
android:duration="1500" />
Jeremy Miller
2,455 PointsThank you sir. Really looking forward to more for android kinda worried it stopped.
Ben Jakuben
Treehouse TeacherSorry about the delay! I am just now starting back on full-time Android course development.