spannablestringbuilder를 애니메이션으로 변환하려고했습니다. 그러나 장치 Logcat : "PropertyValuesHolder : 대상 클래스 클래스에서 float 유형의 메소드 setAlpha()"로부터이 메시지가 나타납니다.ObjectAnimator를 사용하여 SpannableStringBuilder 애니메이션을 적용 할 수 없습니다.
순수한 문자열에 애니메이션을 적용하는 방법에 대한 아이디어는 무엇입니까?
내가 무엇을 해왔의 코드 : 유형 getSpans 호출 (당신이 텍스트 뷰와 같은 유형을 지정)하는 setAlpha 방법이없는에서 스팬에 대해 반환
private static void fadeEnhancedText(Context context,TextView labText, TextView labEnchangedText,
int defaultColor) {
//animation add objectanimation
SpannableStringBuilder mSpannableStringBuilder=
new SpannableStringBuilder(labEnchangedText
.getText().toString());
mSpannableStringBuilder.setSpan(mForegroundColorSpan, mMatcher.start(),
mMatcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
labText.setText(labEnchangedText.getText().toString());
labText.setVisibility(View.GONE);
//TODO spannable problem fader doesn't work fully
labEnchangedText.setText(mSpannableStringBuilder, TextView.BufferType.SPANNABLE);
mAnimationSet.play(fadeIn(labEnchangedText,mSpannableStringBuilder)).
after(fadeOut(labEnchangedText,
labText,
defaultColor,mSpannableStringBuilder));
mAnimationSet.start();
}
private static ObjectAnimator fadeIn(TextView textView, SpannableStringBuilder spannableStringBuilder)
{
ObjectAnimator animation = ObjectAnimator.ofFloat(spannableStringBuilder.getSpans(mMatcher.start(),
mMatcher.end(),textView.getClass()), "alpha",0f,1f);
animation.setDuration(300);
return animation;
}
private static ObjectAnimator fadeOut(final TextView textView, final TextView currentView, final int defaultColor,
final SpannableStringBuilder spannableStringBuilder)
{
//textView.setTextColor(Color.rgb(177, 24, 46));
ObjectAnimator animation = ObjectAnimator.ofFloat(spannableStringBuilder.getSpans(mMatcher.start(),
mMatcher.end(),textView.getClass()), "alpha",1f,0f);
animation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
textView.setTextColor(defaultColor);
currentView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animation.setRepeatCount(4);
animation.setDuration(300);
return animation;
}