@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
((ImageView) v).setColorFilter(Color.argb(150, 155, 155, 155));
} else {
((ImageView) v).setColorFilter(Color.argb(0, 155, 155, 155));
}
}
};
public final static OnTouchListener buttonOnTouchListener=new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN){
((ImageView) v).setColorFilter(Color.argb(150, 155, 155, 155));
return true;
}
else if(event.getAction() == MotionEvent.ACTION_UP){
((ImageView) v).setColorFilter(Color.argb(0, 155, 155, 155));
return true;
}
return false;
}
};
- button.setOnTouchListener(buttonOnTouchListener);
- button.setOnFocusChangeListener(buttonOnFocusChangeListener);
沒有留言:
張貼留言