0
零差錯,我得到的方法applyTransformation零誤差鴻溝在機器人動畫類:除以上applyTransformation
05-15 21:13:59.330: E/AndroidRuntime(16997): java.lang.ArithmeticException: divide by zero
05-15 21:13:59.330: E/AndroidRuntime(16997): at com.special.ResideMenuDemo.FontResize.applyTransformation(FontResize.java:34)
這就是我的applyTransformation方法:
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
SpannableStringBuilder spanTxt = new SpannableStringBuilder("He");
int length = spanTxt.length();
for (int i = 0; i < length; i++) {
/*Log.e("Log", "length : " + length + "\r\n" +
"i : " + i + "\r\n" +
"interpolatedTime : " + interpolatedTime);*/
float size = 1/(1/length * (i+1)) * interpolatedTime;
if(size >= 1)
continue;
spanTxt.setSpan(new RelativeSizeSpan(size), i, i+1, 0);
}
text.setText(spanTxt);
}
的第一個字母的大小應該是0,如果interpolatedTime是0
float size = 1/(1/length * (i+1)) * interpolatedTime;
float size = 1/(1/2 * (0 + 1)) * 0,0;
但我得到的錯誤div ide by zero