为了增加一个按钮的大小,当它在Android的pssed $ P $它在、按钮、大小、pssed

2023-09-06 22:21:49 作者:从小就拉风

我怎样才能当pressed我按钮的大小略有增加,并释放时再次减小?这是为突出pressed按钮,通过除了不同的颜色使用大小

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.

问候,奇奇

推荐答案

请您按钮字段,并在 OnTouchListener 与它相关联。使用OnTouchListener你可以听不同的 MotionEvents ,如 ACTION_DOWN ACTION_UP

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.