2017-09-01 88 views
0

我試圖通過動畫顯示給用戶的字符的行或路徑來顯示我的Android應用程序中插圖的導出SVG文件的動畫效果(例如:日文&漢字)。但是當我運行該應用程序時,它只會動畫角色的邊緣/中風並恢復到原始狀態。有沒有人曾經遇到過這種情況?在Android中繪製矢量的動畫路徑

這裏是我的SVG繪製

<vector xmlns:android="http://schemas.android.com/apk/res/android" 
    android:width="300dp" 
    android:height="300dp" 
    android:viewportWidth="300.0" 
    android:viewportHeight="300.0"> 
<path 
    android:name="invertu" 
    android:fillColor="#FF000000" 
    android:pathData="M21.23,263.43c0.68,-14.76 6.03,-28.9 
9.58,-43.12c3.82,-15.3 6.51,-30.8 10.68,-46.04c4.22,-15.46 9.06,-30.74 
14.02,-45.97c3.7,-11.38 7.53,-22.54 14.07,-32.66c14.19,-21.95 43.47,-29.83 
67.74,-33.8c13.6,-2.22 27.52,-2.66 41.27,-2.32c10.71,0.27 21.44,2.13 
31.29,6.5c28.73,12.76 43.98,42.42 53.04,70.95c5.67,17.85 9,36.29 
12.31,54.69c4.36,24.27 7.8,48.7 8.3,73.39c0.19,9.66 15.19,9.68 
15,0c-0.65,-32.46 -6.33,-64.51 -12.34,-96.33c-4.07,-21.5 -9.94,-42.7 
-19.22,-62.57c-8.76,-18.76 -21.57,-35.7 -38.92,-47.24c-20.15,-13.41 
-44.1,-15.18 -67.61,-14.26c-24.9,0.97 -49.66,5.88 -72.26,16.55c-20.76,9.8 
-33.38,26.41 -41.69,47.37c-4.61,11.65 -8.1,23.81 -11.83,35.77c-4.22,13.53 
-8.13,27.16 -11.53,40.92c-3.27,13.2 -5.45,26.61 -9.05,39.73c-3.47,12.65 
-7.23,25.26 -7.84,38.45C5.79,273.11 20.79,273.06 21.23,263.43L21.23,263.43z" 
    android:strokeLineCap="round" 
    android:strokeLineJoin="round" 
    android:strokeWidth="3" 
    android:trimPathEnd="0"/> </vector> 

,這是我的動畫矢量

<animated-vector 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:aapt="http://schemas.android.com/aapt" 
    android:drawable="@drawable/ic_ba"> 

    <target android:name="invertu"> 
    <aapt:attr name="android:animation"> 
     <objectAnimator 
     android:duration="1000" 
     android:interpolator="@android:interpolator/fast_out_slow_in" 
     android:propertyName="trimPathEnd" 
     android:valueFrom="0" 
     android:valueTo="1"/> 
    </aapt:attr> 
    </target> 

,我已經從Adobe Illustrator導出的VSG在中心變得透明,只有輪廓從動畫一點到另一端。 Vector Path TIA

回答

1

trimPathStarttrimPathEnd旨在僅設置路徑的行程(輪廓)的開始和結束。如果你想讓路徑的填充部分變成動畫,你必須以另一種方式來做。

如果角色中的線條形狀具有恆定的寬度,那麼只需將它們繪製成粗線 - 而不是像現在這樣的輪廓。如果你這樣做,可以使用trimPath方法對線條進行動畫處理。

+0

是的,我把它畫成一個實線,但是當我將它用於amdroid時,它變得透明,我不知道它是否與illustrator設置或android studio本身有關 – vidalbenjoe

+0

很難說沒有看到它。 –

+0

嗨,請參閱我的問題從Android工作室的矢量預覽附加圖像。矢量繪圖應該是堅實的,因爲它是從Illustrator中導出的,但是當我將它導入到android studio時,它在中心變得透明,並且只繪製輪廓。 – vidalbenjoe