-1

I need to do an animation for my button that changes its color from inside out without any flickering.It means the color should change from the center and the button should be stable.The button should not shrink or fade.The button color should change from the center point of button to the overall button.

Cool strom
  • 35
  • 1
  • 5
  • Are you looking for something like ripple effect just like we have for calculators etc in lolipop and marshmallow versions ? – Preetika Kaur Sep 16 '16 at 04:39
  • yes but to fill the button with another color from center of button to the entire button – Cool strom Sep 16 '16 at 06:14
  • Possible duplicate of [change button text color when pressed](http://stackoverflow.com/questions/9335279/change-button-text-color-when-pressed) – Soham Sep 16 '16 at 06:54

1 Answers1

3

res/drawable/effect.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/colorPrimary"/>
    <item android:state_pressed="true" android:drawable="@color/your_red_color" />
</selector>

Add effect.xml as background of button:

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/effect"
    android:text="Click Me" /> 
W4R10CK
  • 5,502
  • 2
  • 19
  • 30