在 textview 上应用 TransitionDrawable 时出现 stackoverflow 错误:
private static void applyAnimationTransitionBackground(String descriptorValue, final Resources resources, View view){
Drawable currentBackground;
TransitionDrawable td;
if (view!=null){
//Get current background or transparent color
currentBackground = view.getBackground();
if (currentBackground==null){
currentBackground = new ColorDrawable(android.R.color.transparent);
}
//Create transition depend on trend
if (descriptorValue.equals("1")){
td= new TransitionDrawable (new Drawable []{currentBackground, new ColorDrawable(resources.getColor(R.color.positive_animation))});
}else if (descriptorValue.equals("2")){
td= new TransitionDrawable (new Drawable []{currentBackground, new ColorDrawable(resources.getColor(R.color.neutral_animation))});
}else{
td= new TransitionDrawable (new Drawable []{currentBackground, new ColorDrawable(resources.getColor(R.color.negative_animation))});
}
//Apply animation
if (td!=null){
view.setBackgroundDrawable(td);
td.startTransition(500);
//td.reverseTransition(500);
}else{
Logger.error("applyAnimationTransitionBackground: TransitionDrawable is NULL");
}
}
}
02-12 17:00:12.899: I/System.out(11217): ---> M SAN nuevo valor 1,52%
02-12 17:00:12.907: I/System.out(11217): ---> M SAN nuevo valor SANTANDER
02-12 17:00:12.907: W/Resources(11217): Converting to string: TypedValue{t=0x11/d=0x55 a=-1}
02-12 17:00:12.907: W/Resources(11217): Converting to string: TypedValue{t=0x10/d=0xfffffffe a=-1}
02-12 17:00:12.915: I/System.out(11217): ---> M SAN nuevo valor 1,52%
02-12 17:00:12.915: I/System.out(11217): ---> M SAN nuevo valor SANTANDER
02-12 17:00:12.915: W/Resources(11217): Converting to string: TypedValue{t=0x11/d=0x55 a=-1}
02-12 17:00:12.915: W/Resources(11217): Converting to string: TypedValue{t=0x10/d=0xfffffffe a=-1}
02-12 17:00:12.915: I/dalvikvm(11217): threadid=1: stack overflow on call to Landroid/view/GLES20Canvas;.setupModifiers:IL
02-12 17:00:12.915: I/dalvikvm(11217): method requires 40+20+20=80 bytes, fp is 0x4016b324 (36 left)
02-12 17:00:12.915: I/dalvikvm(11217): expanding stack end (0x4016b300 to 0x4016b000)
02-12 17:00:12.915: I/dalvikvm(11217): Shrank stack (to 0x4016b300, curFrame is 0x4016e420)
02-12 17:00:12.915: D/AndroidRuntime(11217): Shutting down VM
02-12 17:00:12.915: W/dalvikvm(11217): threadid=1: thread exiting with uncaught exception (group=0x40bd91f8)
02-12 17:00:12.961: E/AndroidRuntime(11217): FATAL EXCEPTION: main
02-12 17:00:12.961: E/AndroidRuntime(11217): java.lang.StackOverflowError
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.view.GLES20Canvas.drawRect(GLES20Canvas.java:942)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.view.GLES20RecordingCanvas.drawRect(GLES20RecordingCanvas.java:226)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.view.GLES20Canvas.drawRect(GLES20Canvas.java:952)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.view.GLES20RecordingCanvas.drawRect(GLES20RecordingCanvas.java:232)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.ColorDrawable.draw(ColorDrawable.java:70)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)
02-12 17:00:12.961: E/AndroidRuntime(11217): at android.graphics.drawable.TransitionDrawable.draw(TransitionDrawable.java:195)