Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
[PhotoGallery] Make sure that the ripple starts from the correct point.
Browse files Browse the repository at this point in the history
Bug: With Android 5.0 the ripple drawable will animate in the foreground, but the ripple will always begin at the center of the view.
https://plus.google.com/+NickButcher/posts/azEU6s4APbu
https://gist.github.com/chrisbanes/9091754 gabrielemariotti commented on Nov 9, 2014
  • Loading branch information
li2 committed Feb 15, 2016
1 parent edfa5dc commit 79ff20f
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -3,11 +3,15 @@
/**
* Created by weiyi on 2/15/16.
*/

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;

public class ForegroundImageView extends ImageView {
Expand Down Expand Up @@ -104,4 +108,17 @@ public void setForeground(Drawable drawable) {
foreground.draw(canvas);
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onTouchEvent(MotionEvent e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (e.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (foreground != null) {
foreground.setHotspot(e.getX(), e.getY());
}
}
}
return super.onTouchEvent(e);
}
}

0 comments on commit 79ff20f

Please sign in to comment.