AlphaAnimation alphaDown,alphaUp;
_button = (Button)findViewById(R.id.button1);
alphaDown =
new
AlphaAnimation(
1
.0f,
0
.5f);
alphaUp =
new
AlphaAnimation(
0
.5f,
1
.0f);
alphaDown.setDuration(
100
);
alphaUp.setDuration(
100
);
alphaDown.setFillAfter(
true
);
alphaUp.setFillAfter(
true
);
_button.setOnTouchListener(
new
View.OnTouchListener() {
@Override
public
boolean
onTouch(View v, MotionEvent event) {
if
(event.getAction()==MotionEvent.ACTION_DOWN)
_button.startAnimation(alphaDown);
if
(event.getAction()==MotionEvent.ACTION_UP)
_button.startAnimation(alphaUp);
return
false
;
}
});
http://hasithdevs.wordpress.com/category/android-2/