views:

79

answers:

2

Hi,

How can I make my button's size to increase slightly when it is pressed and decrease again when it is released? This is for highlighting the pressed button, by using size in addition to a different color.

Regards, Kiki

+1  A: 

Make your Button a field, and modify its size in the OnTouchListener associated with it. Using an OnTouchListener you can listen for different MotionEvents, such as ACTION_DOWN and ACTION_UP.

fredley
Thank you, Fredley!
kiki
A: 

In your activity

Private Button myButton;

//...

protected void onCreate(Bundle savedInstanceState) {

//...

myButton = (Button) findViewById(R.id.my_button);
    _button.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        myButton.setWidth(50);
        myButton.setHeight(50);
        }
      });
    }
yann.debonnel
But my issue is to increase button size when pressed and get back to normal size when button is released.
kiki