animated-vector показывает только небольшую часть вектора - PullRequest
0 голосов
/ 14 марта 2019

Я генерирую анимацию в https://shapeshifter.design/ и экспортирую ее в animatedvectorDrawable. Но когда я пытаюсь запустить на Android, он показывает одну маленькую часть. Если я удаляю анимацию в анимированном векторе или экспортирую ее из фигурного преобразователя, такого как вектор, который можно нарисовать без анимации, тоже будет работать нормально. Просто покажите букву "О".

Моя деятельность:

public class MainActivity extends AppCompatActivity {

private ImageView imgvLaucherViasoft;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    imgvLaucherViasoft = findViewById(R.id.laucher_viasoft);
    animate();
}

public void animate () {
    Drawable d = imgvLaucherViasoft.getDrawable();
    if (d instanceof AnimatedVectorDrawableCompat) {
        AnimatedVectorDrawableCompat avd = (AnimatedVectorDrawableCompat) d;
        avd.start();
    } else if (d instanceof AnimatedVectorDrawable) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d;
        avd.start();
    }

}
}

расположение:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".MainActivity">

<ImageView
    android:id="@+id/laucher_viasoft"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:src="@drawable/avd_anim"
    android:scaleType="centerCrop"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:contentDescription="@string/splash_animation" />

 </android.support.constraint.ConstraintLayout>

AnimatedVectorDrawable

<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
    <vector
        android:name="vector"
        android:width="299dp"
        android:height="90dp"
        android:viewportWidth="299"
        android:viewportHeight="90">
        <path
            android:name="path"
            android:pathData="M 183.645 29.848 C 171.344 29.848 168.613 30.152 166.363 31.875 C 164.117 33.594 163.453 36.594 163.453 44.797 C 163.453 53.441 164.07 56.352 166.363 58.117 C 168.613 59.848 171.348 60.152 183.73 60.152 C 195.898 60.152 198.676 59.848 200.922 58.117 C 203.168 56.391 203.832 53.441 203.832 44.973 C 203.832 36.551 203.168 33.594 200.922 31.875 C 198.672 30.156 195.938 29.848 183.641 29.848 M 197.43 37.414 L 194.539 40.426 C 194.781 41.539 194.883 43.191 194.883 45.813 C 194.883 49.387 194.574 50.664 193.559 51.457 C 192.371 52.34 190.914 52.516 183.73 52.516 C 176.324 52.516 174.914 52.387 173.723 51.457 C 172.668 50.621 172.402 49.43 172.402 45.77 C 172.402 42.02 172.695 40.398 173.105 39.328 C 174.672 35.25 192.309 37.891 197.434 37.414 Z M 124.973 49.957 L 124.973 51.371 C 124.973 55.43 125.633 57.148 127.66 58.422 C 129.734 59.754 133.305 60.152 142.43 60.152 C 151.199 60.152 154.902 59.93 156.668 59.262 C 159.703 58.113 160.941 55.602 160.941 50.484 C 160.941 46.383 160.191 44.398 158.164 43.074 C 156.27 41.883 154.375 41.664 144.672 41.355 C 138.457 41.176 136.035 41.043 135.242 40.824 C 134.313 40.602 133.918 40.031 133.918 38.926 C 133.918 36.766 134.535 36.59 142.117 36.59 C 148.465 36.59 149.566 36.68 150.316 37.121 C 150.977 37.516 151.109 37.914 151.195 39.547 L 159.836 39.547 C 159.879 38.973 159.879 38.355 159.879 38.18 C 159.879 34.695 159.176 32.84 157.41 31.652 C 155.344 30.238 152.254 29.844 143.703 29.844 C 136.652 29.844 132.594 30.02 130.875 30.371 C 126.82 31.254 125.234 33.766 125.234 39.371 C 125.234 45.855 127.262 47.707 134.535 47.93 L 136.914 48.016 L 141.676 48.238 L 148.727 48.5 C 151.59 48.547 152.25 48.988 152.25 50.75 C 152.25 53.352 152.25 53.352 142.641 53.352 C 136.336 53.352 135.367 53.266 134.531 52.738 C 133.824 52.293 133.648 51.723 133.648 49.957 Z M 113.27 57.215 L 114.527 59.707 L 124.703 59.707 L 109.324 30.285 L 95.395 30.285 L 79.828 59.707 L 90.066 59.707 C 93.848 52.133 97.59 44.676 101.438 37.125 L 103.203 37.125 C 104.84 40.34 106.445 43.516 108.035 46.691 L 113.34 46.691 L 109.352 49.328 C 110.66 51.945 111.965 54.57 113.27 57.215 Z M 69.125 30.285 L 69.125 59.703 L 78.52 59.703 L 78.52 30.285 Z M 25.039 30.285 L 39.594 59.703 L 53.301 59.703 L 67.672 30.285 L 57.883 30.285 L 47.309 52.297 L 45.586 52.297 L 34.875 30.285 Z M 251.477 37.781 L 251.477 59.707 L 260.867 59.707 L 260.867 37.785 L 273.961 37.785 L 273.961 30.285 L 207.355 30.285 L 207.355 59.703 L 216.305 59.703 L 216.305 49.516 L 233.039 49.516 L 237.328 42.77 L 216.301 42.77 L 216.301 37.77 Z M 251.477 37.781"
            android:strokeColor="#a3a3a3"
            android:strokeWidth="1"
            android:strokeLineCap="square"
            android:strokeMiterLimit="5"
            android:fillType="evenOdd"/>
    </vector>
</aapt:attr>
<target android:name="path">
    <aapt:attr name="android:animation">
        <set>
            <objectAnimator
                android:propertyName="trimPathEnd"
                android:duration="1000"
                android:valueFrom="0"
                android:valueTo="1"
                android:valueType="floatType"
                android:interpolator="@android:interpolator/fast_out_slow_in"/>
            <objectAnimator
                android:propertyName="trimPathStart"
                android:startOffset="1000"
                android:duration="1000"
                android:valueFrom="0"
                android:valueTo="1"
                android:valueType="floatType"
                android:interpolator="@android:interpolator/fast_out_slow_in"/>
            <objectAnimator
                android:propertyName="fillColor"
                android:duration="1000"
                android:valueTo="#ff141f"
                android:valueType="colorType"

        android:interpolator="@android:interpolator/fast_out_slow_in"/>
        </set>
    </aapt:attr>
</target>
</animated-vector>

Обновление: Я нашел часть проблемы. Буква «О» - это первая часть пути, а когда начинается следующий путь, она все игнорируется. Пример:

* Тысячу двадцать-два * М 183,645 29,848 С 171,344 29,848 168,613 30,152 166,363 31,875 C 164,117 33,594 163,453 36,594 163,453 44,797 C 163,453 53,441 164,07 56,352 166,363 58,117 C 168,613 59,848 171,348 60,152 183,73 60,152 С 195,898 60,152 198,676 59,848 200,922 58,117 C 203,168 56,391 203,832 53,441 203,832 44,973 C 203,832 36,551 203,168 33,594 200,922 31,875 C 198,672 30,156 195,938 29,848 183,641 29,848 M (буква «M» начинает другую часть с вектора)

Не знаю, почему это происходит.

...