Skip to content

Instantly share code, notes, and snippets.

@subinkrishna
Created July 14, 2016 17:25
Show Gist options
  • Save subinkrishna/8eca07566644ffdc99edf0a8308d1d0e to your computer and use it in GitHub Desktop.
Save subinkrishna/8eca07566644ffdc99edf0a8308d1d0e to your computer and use it in GitHub Desktop.
Animating the value in the TextView. Eg: change the value in a stock ticker
final Property<TextView, Integer> textValueProperty = new Property<TextView, Integer>(Integer.class, "textValue") {
@Override public Integer get(TextView textView) {
return Integer.parseInt(textView.getText().toString());
}
@Override public void set(TextView textView, Integer value) {
textView.setText(String.valueOf(value));
}
};
ObjectAnimator anim = ObjectAnimator.ofInt(animatingTextView,
textValueProperty,
1, // Start value
10); // End value
anim.setDuration(2000).setInterpolator(new DecelerateInterpolator());
anim.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment