Q:

Default Button's methods

I'd like to gain after onclick button efect similar to default in android, but with own colors
Default button is white or light gray
When i touch button color is changed for one moment (orange)
when release, button's color back to original color (white/light gray)
Which method's are using to this effect ?
I used onTouchListener() to set touched button color
and OnClickListener() to set back original color
But when i scroll group button(inner ScrollView) when i touch any button, color changed but when release button color ofc not change back. Which method should i use ? How can i fix that ?
///////////////////
I created colors in values and define 2 colors
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="white">#ffffff</color>
    <color name="blue">#004080</color>
</resources>

I create new folder color and button_state.xml inner this folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_focused="true"
        android:state_pressed="false"
        android:drawable="@color/blue" />
    <item android:state_focused="true"
        android:state_pressed="true"
        android:drawable="@color/white" />
</selector>

to my button i assign code in xml file
android:background="@color/button_states"

Now my button have no background, but i don't know why

A:

create xml file defining button states and button color depending on state, for example button_states.xml in res/color folder in your project:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:drawable="@color/pressed_button_color"/>
    <item android:state_selected="true"
          android:drawable="@color/selected_button_color"/>
    <item android:drawable="@color/default_button_color"/>
</selector>

define these colors in values/colors.xml
and use this in your layout xml file on the Button element as:
android:background="@color/button_states"

