Created SquaredImageView

This commit is contained in:
Severiano Jaramillo 2018-01-24 23:21:04 -06:00
parent 45657e414f
commit 902d2c77ef

View file

@ -0,0 +1,33 @@
package cy.agorise.crystalwallet.util;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
/**
* Created by xd on 1/24/18.
* ImageView which adjusts its size to always create a square
*/
public class SquaredImageView extends AppCompatImageView {
public SquaredImageView(Context context) {
super(context);
}
public SquaredImageView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public SquaredImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
setMeasuredDimension(size, size);
}
}