How to make TextView Blink in android

Sometimes , you should be need the textview blink like a digital clock. here is the simple code for you should make blink textview in android. I have discussed here , mainly 3 methods,

Method 1:

private void blinkTextView(){
    final Handler handler = new Handler();
    new Thread(new Runnable() {
        public void run() {
        int timeToBlink = 1000;    //in milissegunds
        try{Thread.sleep(timeToBlink);}catch (Exception e) {}
   Runnable() {
                    public void run() {
                    TextView tvBlink = (TextView) findViewById(;
                    if(tvBlink .getVisibility() == View.VISIBLE){
                        tvBlink .setVisibility(View.INVISIBLE);
                        tvBlink .setVisibility(View.VISIBLE);

call the blinkTextView in onCreate, if you want blink textview whenever load application.

Method 2:

TextView tvBlink = (TextView) findViewById(;

Animation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(50); //You can manage the blinking time with this parameter
tvBlink .startAnimation(anim);

Method 3:

final ObjectAnimator textColorAnim;

and in onCreate, there should be

TextView blinkText = (TextView) findViewById(;
blinkTextView(blinkText );

Now definition of above function:

private void blinkTextView(TextView blinkTextView){
       textColorAnim = ObjectAnimator.ofInt(blinkTextView, "textColor", Color.BLACK, Color.TRANSPARENT);
                textColorAnim.setEvaluator(new ArgbEvaluator());  

How to make TextView Blink in android How to make TextView Blink in android Reviewed by D Kshetri on 12:53 PM Rating: 5

1 comment:

Powered by Blogger.