I have an ImageView
for which I'd like to show an indeterminate progress spinner until the image has been loaded. Ideally, I'd like to point to the drawable itself from my layout xml file, and then simply swap the image in code.
Here's the xml for the drawable; all it shows is a static image that doesn't spin.
<animated-rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/spinner"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:duration="500" />
I've also tried it with just the <rotate>
root tag and the result is the same. Is there something I'm missing?
I've solved my own problem in a much simpler way. I have a FrameLayout
with two children: the custom ImageView
, and an indeterminate ProgressBar
. When the image finishes loading, I make the ProgressBar
gone.
Load the Animation from your anim folder and than call startAnimation to play it:
final ImageView ivRotate = (ImageView) findViewById(R.id.iv_rotate);
Animation rotate = AnimationUtils.loadAnimation(this, R.anim.rotate_picture);
ivRotate.startAnimation(rotate);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.