我想点击一个视图,当它被按下时,它需要在释放视图后缩小比例,它将回到它的宽度和高度 我怎么做..可以帮助任何人。
谢谢 Sajal Biswas 9903076025
答案 0 :(得分:0)
为OnTouchListener
或覆盖View
方法设置正确的onTouchEvent
(如果是自定义视图)。像这样(例子包括第一种方法):
yourView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// apply the change to the dimensions of your view;
// for example with animation and using scale parameters, like this:
v.animate().scaleX(0.6f).scaleY(0.6f);
return true;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
// revert to the normal dimensions of your view
// for example with animation and using scale parameters, like this:
v.animate().scaleX(1f).scaleY(1f);
break;
}
return false;
}
});