카테고리 없음
Android button ontouch fadeout effect
[czar]
2013. 7. 24. 20:55
AlphaAnimation alphaDown,alphaUp;
_button = (Button)findViewById(R.id.button1);
//set animation
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
);
//set OnTouchListener
_button.setOnTouchListener(
new
View.OnTouchListener() {
@Override
public
boolean
onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if
(event.getAction()==MotionEvent.ACTION_DOWN)
_button.startAnimation(alphaDown);
if
(event.getAction()==MotionEvent.ACTION_UP)
_button.startAnimation(alphaUp);
return
false
;
}
});