了解で、す…!
以下、タッチイベントとAnimation使ってやる方法。
仕込み
AnimUtils.java
public static void setOnTouchAnimation(View targetView, final float scaleX,
final float scaleY) {
targetView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
AnimUtils.onTouchAnimate(v, event.getAction(), scaleX, scaleY);
return false;
}
});
}
public static void onTouchAnimate(View targetView, int action,
float scaleX, float scaleY) {
if (action == MotionEvent.ACTION_DOWN) {
ScaleAnimation anim = new ScaleAnimation(1.0f, scaleX, 1.0f,
scaleY, targetView.getWidth() / 2,
targetView.getHeight() / 2);
anim.setDuration(60);
anim.setFillEnabled(true);
anim.setFillAfter(true);
targetView.startAnimation(anim);
} else if (action == MotionEvent.ACTION_CANCEL
|| action == MotionEvent.ACTION_UP) {
ScaleAnimation anim = new ScaleAnimation(scaleX, 1.0f, scaleY,
1.0f, targetView.getWidth() / 2, targetView.getHeight() / 2);
anim.setDuration(100);
targetView.startAnimation(anim);
}
}
ボタン拡大のためだけにsetOnTouchListenerする場合
AnimUtils.setOnTouchAnimation(view, 1.1f, 1.1f);
サイズにもよるけど1.02f~1.1fがイイ具合
setOnTouchListenerの実装にお邪魔する場合
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
// アニメ処理挟む
AnimUtils.onTouchAnimate(v, action, 1.1f, 1.1f);
// 何かしらの実装部分
}
});
こっちは今のところ妄想パターン