Created
July 14, 2016 17:25
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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