Google Android News Android Forums

PCWorld How-To's and Tips

PCWorld Latest Technology News

Saturday, June 19, 2010

How to Change the Color of an image when Clicked in Android ?

Well ,in advanced mobile applications or normal ones , a developer should communicate with the user using some feed backs so changing the color of an image or label when clicked gives the user the feedback that he has really clicked something, here how it is done :-

In your onClick() method , use the following method :
-setColorFilter("color in hexa" , "mode") , in my case I use
-button.setColorFilter(0x77000000,Mode.SRC_ATOP);

doing this you will change the Colour but if you pressed the back button , you will find it stuck on the colour you changed ,to return things as they were you can either use -setColorFilter(null) or setColorfilter(Color.TRANSPARENT,Mode.SRC_ATOP)

I use setColorFilter(null) and this does the trick for me

No comments:

Post a Comment