Last active
August 29, 2015 14:08
-
-
Save cuber5566/34df8cb3f54221626db1 to your computer and use it in GitHub Desktop.
This file contains 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
package com.imagecrop; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Path; | |
import android.graphics.Rect; | |
import android.graphics.Region; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class ImageCrop extends ImageView { | |
Path path = new Path(); | |
public ImageCrop(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
protected void onDraw(Canvas canvas) { | |
Rect rect = canvas.getClipBounds(); | |
path.moveTo(250, 0); | |
path.lineTo(rect.right, 0); | |
path.lineTo(rect.right, rect.bottom - 250); | |
path.lineTo(rect.right-250, rect.bottom); | |
path.lineTo(0, rect.bottom); | |
path.lineTo(0,250); | |
path.close(); | |
canvas.clipPath(path); | |
super.onDraw(canvas); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment