I have an ImageView object where both its Background and drawable attributes are set. I need to animate the drawable part of the ImageView while the background stay still.
I can't find a way to do it...
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:drawable="@drawable/ic_popup_sync_1"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:duration="1200"
android:toDegrees="360" />
imageView.startAnimation(AnimationUtils.loadAnimation(context, animId));
Both the drawable and the background are rotating at the same time...
Set the background to a separate layout that sits behind the ImageView
. Put both into a RelativeLayout
where the background View
is aligned to the ImageView
by left, right, top, and bottom so that the background stays within the image's bounds. Then you can rotate the image freely.
EDIT:
Better yet, but the ImageView
inside a layout and set the layout to WRAP_CONTENT
. Set the layout's background to your background image.
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.