Created
May 27, 2014 13:58
-
-
Save cesarferreira/4fcae632b18904035d3b to your computer and use it in GitHub Desktop.
Make a View Blink for a desired duration (android)
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
// Animate a text view | |
TextView myText = (TextView) findViewById(R.id.textView1); | |
myText = (TextView)Utils.makeMeBlink(myText,250,20); | |
// Animate an image view | |
ImageView imageView = (ImageView) findViewById(R.id.imageView); | |
imageView = (ImageView)Utils.makeMeBlink(imageView,250,20); | |
/** | |
* Make a View Blink for a desired duration | |
* | |
* @param view view that will be animated | |
* @param duration for how long in ms will it blink | |
* @param offset start offset of the animation | |
* @return returns the same view with animation properties | |
*/ | |
public static View makeMeBlink(View view, int duration, int offset) { | |
Animation anim = new AlphaAnimation(0.0f, 1.0f); | |
anim.setDuration(duration); | |
anim.setStartOffset(offset); | |
anim.setRepeatMode(Animation.REVERSE); | |
anim.setRepeatCount(Animation.INFINITE); | |
view.startAnimation(anim); | |
return view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi ,
will it hide textview and remove animation after time interval ?