2

In my application, I have recording button. I want when user clicks on it each one second i change the background in order to simulate blinking. I created a handler and set it to 1 second therefore each one second this handler runs. Here i change the background. this my code:

mUpdateUITimerTask = new Runnable() {
            public void run() {

                // Simulating blinking for capture button
                if(bolToggle) {
                    bolToggle = false;
                    captureButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_record_blink));
                } else {
                    bolToggle = true;
                    captureButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.btn_record));
                }

                mHandler.postDelayed(mUpdateUITimerTask, 1000);
            }
        };

When I run the app i see the changes but its not clear. buttons are like this: enter image description here

When i run the application, red image is showing ok but for white image, it shows red image with a little white halo around it. I tried to put captureButton.setBackgroundColor(Color.TRANSPARENT); before setting background but result was same.

any suggestion would be appreciated. Thank you.

Hesam
  • 52,260
  • 74
  • 224
  • 365
  • won't fix your problem, but FYI you can use `captureButton.setBackgroundResource(R.drawable.btn_record);` to save yourself some typing – JRaymond Apr 26 '12 at 01:45
  • Thanks dear JRaymond, You are right its easier :) result was same as well. – Hesam Apr 26 '12 at 01:49

1 Answers1

7

Found the answer you need: https://stackoverflow.com/a/4852468/1352556

Basically you want an alpha animation. I believe this will make the entire button flash however, do you only want the red dot flashing?

Community
  • 1
  • 1
Drew
  • 111
  • 4
  • Thanks dear Drew, I just need to exchange background of my button. I'll do your suggestion and will tell you the result. – Hesam Apr 26 '12 at 02:04
  • It is working fine. I'll use your suggestion instead of swapping images. thanks again – Hesam Apr 26 '12 at 02:13