Android-аниматор объектов поворачивается относительно себя xml - PullRequest
0 голосов
/ 08 октября 2018

Я пытаюсь создать поворот Object Animator в xml.Прямо сейчас вращение, кажется, имеет точку поворота, равную 0,0, так как я могу изменить точку поворота, чтобы она была центром вида?

<objectAnimator
    android:duration="100"
    android:interpolator="@android:anim/linear_interpolator"
    android:propertyName="rotation"
    android:repeatCount="-1"
    android:valueFrom="0"
    android:valueTo="180"
    android:valueType="floatType"/>

1 Ответ

0 голосов
/ 08 октября 2018

Вы можете использовать RotateDrawable.Попробуйте приведенный ниже фрагмент кода:

Программно:

Animation animation = AnimationUtils.loadAnimation(context, R.anim.rotation);
view.startAnimation(animation);

anim / вращение. XML:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="500"
    android:fromDegrees="0"
    android:toDegrees="180"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="1"
    android:repeatMode="reverse"
    android:interpolator="@android:anim/linear_interpolator" />

Здесьрезультат:

enter image description here

...