0

I have two images(Light Red and Dark Red) for the button and i want to give Flashing Effect to that button that initially it glows from light-red to Dark-red and then when it pressed, its state will be changed to dark red. i try to sort out the Solution for this but every-where i see Fade-in and Fade-out solution using one image, but i want to use both images.

Please let me know if any function exists there for giving Flashing Effect between two images or i will have to make it manually.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
Haider Ali
  • 41
  • 7

2 Answers2

1

For this I think you have to use customized xml drawable for your button, And for different state of button you can use different images, to apply style

Try this,

example:

XML file saved at res/drawable/button.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">    
<item android:state_pressed="true"          
      android:drawable="@drawable/button_pressed" /> <!-- pressed -->    
<item android:state_focused="true"          
      android:drawable="@drawable/button_focused" /> <!-- focused -->    
<item android:state_hovered="true"          
      android:drawable="@drawable/button_focused" /> <!-- hovered -->    
<item android:drawable="@drawable/button_normal" />  <!-- default -->
</selector>

This layout XML applies the state list drawable to a Button:

<Button    android:layout_height="wrap_content"    
           android:layout_width="wrap_content"    
           android:background="@drawable/button" />

For more info look at Android - Drawable Style.

And nice example Adding Gradient Effects to Android Button.

SO post how to set image button backgroundimage for different state?.

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151
0

You will need to work with associating Animations to Buttons.

Here are some links to tutorials :

Reno
  • 33,594
  • 11
  • 89
  • 102