diff options
Diffstat (limited to 'app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java')
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java b/app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java new file mode 100644 index 0000000..ed5dbb7 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/SquareImageView.java @@ -0,0 +1,28 @@ +package org.marcinzelent.liberavem; + +import android.content.Context; +import android.util.AttributeSet; + +public class SquareImageView extends android.support.v7.widget.AppCompatImageView { + + public SquareImageView(Context context) { + super(context); + } + + public SquareImageView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SquareImageView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + int width = getMeasuredWidth(); + setMeasuredDimension(width, width); + } + +} |