react-native-navigation的迁移库

TextSizeAnimator.java 1.0KB

12345678910111213141516171819202122232425262728293031323334
  1. package com.reactnativenavigation.views.element.animators;
  2. import android.animation.Animator;
  3. import android.animation.ObjectAnimator;
  4. import android.widget.TextView;
  5. import com.facebook.react.views.text.ReactTextView;
  6. import com.reactnativenavigation.utils.TextViewUtils;
  7. import com.reactnativenavigation.views.element.Element;
  8. import static com.reactnativenavigation.utils.TextViewUtils.getTextSize;
  9. public class TextSizeAnimator extends PropertyAnimatorCreator<ReactTextView> {
  10. public TextSizeAnimator(Element from, Element to) {
  11. super(from, to);
  12. }
  13. @Override
  14. protected boolean shouldAnimateProperty(ReactTextView fromChild, ReactTextView toChild) {
  15. return getTextSize(fromChild) != getTextSize(toChild);
  16. }
  17. @Override
  18. public Animator create() {
  19. return ObjectAnimator.ofFloat(
  20. to,
  21. "textSize",
  22. TextViewUtils.getTextSize((TextView) from.getChild()),
  23. TextViewUtils.getTextSize((TextView) to.getChild())
  24. );
  25. }
  26. }