Created
March 6, 2016 05:30
-
-
Save maoruibin/3044a47284312a234ae6 to your computer and use it in GitHub Desktop.
Create a ImageView effect when press
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
switch (event.getAction()) { | |
case MotionEvent.ACTION_DOWN: | |
Drawable drawable = getDrawable(); | |
if (drawable != null) { | |
drawable.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY); | |
} | |
break; | |
case MotionEvent.ACTION_MOVE: | |
break; | |
case MotionEvent.ACTION_CANCEL: | |
case MotionEvent.ACTION_UP: | |
Drawable drawableUp = getDrawable(); | |
if (drawableUp != null) { | |
drawableUp.mutate().clearColorFilter(); | |
} | |
break; | |
} | |
return super.onTouchEvent(event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
实现点击图片 变暗的操作