button.setOnTouchListener (новый View.OnTouchListener () {
@Override
public boolean onTouch(View v, MotionEvent event) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)v.getLayoutParams();
//Code to convert height and width in dp.
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 140, getResources().getDisplayMetrics());
if(event.getAction() == MotionEvent.ACTION_DOWN){
layoutParams.width = width + 5;
layoutParams.height = height + 5;
SearchButton.setLayoutParams(layoutParams);
}
if(event.getAction() == MotionEvent.ACTION_UP){
layoutParams.width = width;
layoutParams.height = height;
SearchButton.setLayoutParams(layoutParams);
}
return false;
}
});