android - How to change image size when pressing -
i'm developing android app , achieve effect haven't found answer to, after searching.
the effect obtain on image. when press image, apply sort of tint on image in order show feedback, go little bit further, wouldn't apply tint sort os scale on image.
e.g. have following image, normal image, , if press image (and while keep pressed), image shrink bit, pressed image
n.b.- black part not part of image, part of background. image blue square.
thank help! :)
p.s.- couldn't post images here because don't have enough reputation.
you need set ontouchlistener of imageview displays image, replaces displayed image. listener runs when press or unpress view (in case image).
sample code:
imageview iv = (imageview)findviewbyid(r.id.my_image_view); iv.setontouchlistener(new imageview.ontouchlistener() { @override public boolean ontouch(view v, motionevent e) { if (e.getaction()==motionevent.action_down) // write code here sets imageview display pressed image else if (e.getaction()==motionevent.action_up) // write code here sets imageview display unpressed image } });
reference ontouchlistener: http://developer.android.com/reference/android/view/view.ontouchlistener.html
reference imageview (for replacing displayed image): http://developer.android.com/reference/android/widget/imageview.html
Comments
Post a Comment