2016-07-21 10 views
2

Ich habe ein animiertes Vector Drawable auf einem Gerät mit API-Ebene versucht, 15.Animation Vector Drawable arbeiten nicht mit API 15

Die laufen folgende ist meine animierten Vektor „animated_feedback.xml“:

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

    <target 
    android:animation="@animator/background_circle_animator" 
    android:name="BG_White_Circle"/> 

</animated-vector> 

The ziehbar "feedback.xml" enthält folgende Komponenten:

<vector xmlns:android="http://schemas.android.com/apk/res/android" 
     android:width="180dp" 
     android:height="180dp" 
     android:viewportWidth="180" 
     android:viewportHeight="180"> 
    <group 
     android:name="BG_White_Circle_Group"> 
     <path 
      android:name="BG_White_Circle" 
      android:fillColor="#fff" 
      android:pathData="M 90 0 C 139.705627485 0 180 40.2943725152 180 90 C 180 139.705627485 139.705627485 180 90 180 C 40.2943725152 180 0 139.705627485 0 90 C 0 40.2943725152 40.2943725152 0 90 0 Z" /> 
     <path 
      android:name="Ring" 
      android:strokeColor="#0094c1" 
      android:strokeWidth="5.00000003634922" 
      android:strokeMiterLimit="10" 
      android:pathData="M 90 9 C 134.735064736 9 171 45.2649352637 171 90 C 171 134.735064736 134.735064736 171 90 171 C 45.2649352637 171 9 134.735064736 9 90 C 9 45.2649352637 45.2649352637 9 90 9 Z" /> 
    </group> 
</vector> 

Und einer der Animateure "background_circle_animator.xml" ist folgende:

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:ordering="sequentially" 
    android:fillAfter="true"> 

    <objectAnimator 
     android:propertyName="fillAlpha" 
     android:valueType="floatType" 
     android:valueFrom="0f" 
     android:valueTo="1f" 
     android:duration="200"/> 

    <objectAnimator 
     android:duration="700"/> 

    <objectAnimator 
     android:propertyName="fillAlpha" 
     android:valueType="floatType" 
     android:valueFrom="1f" 
     android:valueTo="0f" 
     android:duration="200"/> 

</set> 

In meinem activity_main.xml habe ich das Image, die diese Animation spielen:

<ImageView 
    android:id="@+id/feedback_ui" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:visibility="invisible"/> 

schließlich in meinem MainActivity.java Ich habe den folgenden Code:

ImageView feedbackUI = (ImageView) findViewById(R.id.feedback_ui); 
feedbackUI.setImageResource(R.drawable.animated_feedback); 

Drawable animation = feedbackUI.getDrawable(); 
if (animation instanceof Animatable) { 
    feedbackUI.setVisibility(View.VISIBLE); 
    ((Animatable) animation).start(); 
} 

Hier finden Sie Meine Größe:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "karim.com.testinganimation" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 

     vectorDrawables.useSupportLibrary = true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.4.0' 
} 

Wenn Sie dies ausführen Code sollten Sie einen weißen Kreis mit einem blauen Ring darüber sehen, und es sollte ein- und ausblenden.

Ich lief diesen Code auf API> 21 Gerät und es lief perfekt.

Wenn ich es auf einem Gerät mit API laufen 15 Ich erhalte den folgenden Absturz, sobald ich die Animation beginnt:

D/PropertyValuesHolder(19300): Can't find native method using JNI, use reflectionjava.lang.NoSuchMethodError: no method with name='set' signature='(F)V' in class Landroid/support/graphics/drawable/VectorDrawableCompat$VFullPath; 
E/PropertyValuesHolder(19300): Couldn't find setter/getter for property null with value type float 
E/PropertyValuesHolder(19300): Couldn't find no-arg method for property null: java.lang.NoSuchMethodException: get [] 
D/AndroidRuntime(19300): Shutting down VM 
W/dalvikvm(19300): threadid=1: thread exiting with uncaught exception (group=0x40a9e1f8) 
E/AndroidRuntime(19300): FATAL EXCEPTION: main 
E/AndroidRuntime(19300): java.lang.NullPointerException 
E/AndroidRuntime(19300): at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:513) 
E/AndroidRuntime(19300): at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:392) 
E/AndroidRuntime(19300): at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:544) 
E/AndroidRuntime(19300): at android.animation.ValueAnimator.start(ValueAnimator.java:934) 
E/AndroidRuntime(19300): at android.animation.ValueAnimator.start(ValueAnimator.java:957) 
E/AndroidRuntime(19300): at android.animation.ObjectAnimator.start(ObjectAnimator.java:370) 
E/AndroidRuntime(19300): at android.animation.AnimatorSet$DependencyListener.startIfReady(AnimatorSet.java:705) 
E/AndroidRuntime(19300): at android.animation.AnimatorSet$DependencyListener.onAnimationEnd(AnimatorSet.java:659) 
E/AndroidRuntime(19300): at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1040) 
E/AndroidRuntime(19300): at android.animation.ValueAnimator.access$900(ValueAnimator.java:49) 
E/AndroidRuntime(19300): at android.animation.ValueAnimator$AnimationHandler.handleMessage(ValueAnimator.java:675) 
E/AndroidRuntime(19300): at android.os.Handler.dispatchMessage(Handler.java:99) 
E/AndroidRuntime(19300): at android.os.Looper.loop(Looper.java:137) 
E/AndroidRuntime(19300): at android.app.ActivityThread.main(ActivityThread.java:4424) 
E/AndroidRuntime(19300): at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime(19300): at java.lang.reflect.Method.invoke(Method.java:511) 
E/AndroidRuntime(19300): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
E/AndroidRuntime(19300): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
E/AndroidRuntime(19300): at dalvik.system.NativeStart.main(Native Method) 
W/ActivityManager( 164): Force finishing activity karim.com.testinganimation/.MainActivity 

Wie kann ich dieses Problem zu beheben, da es sehr wichtig ist auf Geräten laufen mit API-Ebene 15.

Antwort

0

ich habe nicht ein API 15 Gerät oder Emulator, dies zu testen, aber es scheint mir, es mit dem Mittel objectAnimator nicht glücklich ist:

<objectAnimator 
    android:duration="700"/> 

Teile des Fehlers Eine Nachricht wie "Setter/Getter für Eigenschaft null konnte nicht gefunden werden" deutet darauf hin, dass versucht wird, einen Animator einzurichten, aber da es keine Details darüber gibt, was der Animator animieren sollte, stürzt er ab.

den Zweck dieses objectAnimator Unter der Annahme, nur die animierte Vektor vor Ausblendung pausieren, um zu bewirken, würde ich so etwas wie dies vorschlagen, versuchen:

<objectAnimator 
    android:propertyName="fillAlpha" 
    android:valueType="floatType" 
    android:valueFrom="1f" 
    android:valueTo="1f" 
    android:duration="700"/> 
+0

, die es dank gelöst :) –

Verwandte Themen